处理浏览器缓存问题
main.js
router.onError((error) => {hasRefreshed = false;console.log("异常===" + error.message);let ind0 = error.message.indexOf('Loading chunk chunk-')let ind2 = error.message.indexOf('failed.')if(ind0 != -1 && ind2 !=-1){console.log('Loading chunk chunk-3f820242 failed---11-----')window.location.reload()}})
vue.config.js
const Timestamp = new Date().getTime(); module.exports = {configureWebpack: {.....}},output: {filename: `static/js/menhu.${Timestamp}.js?v=${Timestamp}`,chunkFilename: `static/js/menhu-[name].${Timestamp}.js?v=${Timestamp}`},// 警告 webpack 的性能提示},css: { extract: { // 打包后css文件名称添加时间戳filename: `css/[name].css?v=${Timestamp}`,chunkFilename: `css/chunk.[id].css?v=${Timestamp}`,},extract: true, //注释css热更新生效// 开启 CSS source maps?sourceMap: true,// css预设器配置项loaderOptions: {},// 启用 CSS modules for all css / pre-processor files.modules: false},}