在vue init webpack-simple模板构建中,一个由路由懒加载的页面只会执行一次,第二次切换回来后这个页面将会是空白,而用vue init webpack模板构建的代码却没有此问题,这是什么原因造成的?
请说明具体版本(vue/vue-router/vue-cli/webpack)
On Sun, Oct 16, 2016, 20:13 Byer Shu [email protected] wrote:
在vue init webpack-simple模板构建中,一个由路由懒加载的页面只会执行一次,第二次切换回来后这个页面将会是空白,而用vue
init webpack模板构建的代码却没有此问题,这是什么原因造成的?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/vuejs/vue-router/issues/789, or mute the thread
https://github.com/notifications/unsubscribe-auth/AFTLl83FJKSu0PYduv0Eu3sCeAOygG1yks5q0hT0gaJpZM4KX9Ps
.
vue-cli 2.4.0
vue-router 2.0.1
vue 2.0.3
webpack 2.1.0-beta.25
webpack-simple使用的是webpack 2.0,请使用System.import()来做懒加载,不要用require。
谢谢!已经解决了!
请问你是怎么解决的,我也碰上了这个问题。。。。
@yuxieweiliang
下面是示例, System.import()是es6写法.
const router = new VueRouter({
routes: [
{ path: '/overview', component: resolve => System.import('./overview.vue') },
{ path: '/state', component: resolve => System.import('./state.vue') }
]
})
安卓4.2以下不兼容懒加载
Most helpful comment
webpack-simple使用的是webpack 2.0,请使用System.import()来做懒加载,不要用require。