此问题时常会出现在安卓各个机型,还会不定时出现这个问题,但在苹果各PC端都不会出现此问题
错误出现原因:安卓中部分内置浏览器对资源文件的加载优化不够,导致资源文件懒加载失败
解决方案:
1.看webpack配置是否正确
PublicPath配置为(vuecli3):publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
即:publicPath:'./'
2.改变路由加载方式(取消懒加载):
import Vue from 'vue'; import Router from 'vue-router'; import store from '../store/vuex.js'; import Home from '../view/signwork/index' // 首页 Vue.use(Router); const routes = [ { path: '/', name: 'signindex', component: Home, meta: {title: "签到/签退"} }, { path: '/signindex', name: 'signindex', component: Home, meta: {title: "签到/签退"} } ]; routes.forEach(route => { route.path = route.path || '/' + (route.name || ''); }); const router = new Router({ routes, }); router.beforeEach((to, from, next) => { const title = to.meta && to.meta.title; if (title) { document.title = title; } //处理错误路径 if (to.matched.length === 0) { from.name ? next({ name: from.name }) : next('/errorinfo'); } else { next(); } let checkload = setInterval(function(){ getconfig() }, 1 * 1800); function getconfig(){ if(store.state.isload){ clearInterval(checkload) }else{ window.location.reload() } } }); export default router
注意的是先去import 资源文件,再去路由中调用,而不是边路由边调用