vue-cli 打包后提交到线上出现 "Uncaught SyntaxError:Unexpected token" 报错

  routers.onError((err) => {

  const pattern = /Loading chunk (d)+ failed/g;

  const isChunkLoadFailed = err.message.match(pattern);

  if (isChunkLoadFailed) {

  let chunkBool = sessionStorage.getItem('chunkError');

  let nowTimes = Date.now();

  if (chunkBool === null || chunkBool && nowTimes - parseInt(chunkBool) > 60000) {//路由跳转报错,href手动跳转

  sessionStorage.setItem('chunkError', 'reload');

  const targetPath = routers.history.pending.fullPath;

  window.location.href = window.location.origin + targetPath;

  }else if(chunkBool === 'reload'){ //手动跳转后依然报错,强制刷新

  sessionStorage.setItem('chunkError', Date.now());

  window.location.reload(true);

  }

  }

  })