vue项目chunk包loading失败解决办法

错误截图:

 

 

解决方法:

// loading chunk 出错处理
router.onError((error) => {
  const pattern = /Loading chunk (\d)+ failed/g
  const isChunkLoadFailed = error.message.match(pattern)
  const targetPath = router.history.pending.fullPath
  if (isChunkLoadFailed) {
    router.replace(targetPath)
  }
})

  

posted @ 2020-07-02 16:24  闯入码途的水产人  阅读(4666)  评论(0编辑  收藏  举报