Uncaught TypeError: (intermediate value)(intermediate value).push is not a function
Loading chunk selectpc failed.
路由配置:,采用的是代码分割,异步加载。
{
path:'/selectpc',
name:'selectpc',
title:'选择省份城市',
component: () => import(/* webpackChunkName: "selectpc" */ '20190520gov/views/selectpc.vue'),
},
...
之前一直没问题,后来加了一个文件上传组件,就有问题了
<div class="weui-uploader__input-box">
<!-- <input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" multiple="" /> -->
<fileupload :fileurl.sync="apply_info.main_pic" :picwidth="1080" width_height="" class="weui-uploader__input" :onUploadFailed="uploadfailed" v-on:startupload="startupload"></fileupload>
</div>
自己写的fileupload组件,也是常规写法。
搜了下原因,应该webpack构建时出现了什么包代码合并时的问题。没有引入fileupload组件时正常,引入后有问题。估计有什么冲突了,,时间不多暂时没时间看,把本路由页面异步加载去掉即可,:
import Selectpc from '20190520gov/views/selectpc.vue'
{
path:'/selectpc',
name:'selectpc',
title:'选择省份城市',
component: Selectpc, //() => import(/* webpackChunkName: "selectpc" */ '20190520gov/views/selectpc.vue'),
},
具体里面可能的冲突,以后再看了。
——————————后续补充——————————
此问题貌似是一个很多人遇到的问题,没有好的根治办法,有一个柔性的容错办法,如下处理:
//兼容处理:Loading chunk {n} failed 的问题
router.onError((error) =>{
const pattern = /Loading chunk (.+?) failed/g;
const isChunkLoadFailed = error.message.match(pattern);
const targetPath = router.history.pending.fullPath;
if (isChunkLoadFailed && targetPath) {
debugger
if(typeof window!='undefined' && window.location){
//带上参数
window.location.replace(targetPath);
}
//router.replace(targetPath);
}
});
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。