vue-cli + webpack2 + Vue-Router2打包文件過大的優化

一、Webpack2 + Vue2 + Vue-Router2 如何實現懶加載?javascript

const Main = resolve => require(['./components/Main.vue'], resolve)
const Home = resolve => require(['./components/Home.vue'], resolve)

const router = new VueRouter({
    mode: 'hash',
    base: __dirname,
    scrollBehavior,
    routes: [
        { name:'main', path: 'main', component: Main },
        { name:'home', path: 'home', component: Home }
    ]
})
相關文章
相關標籤/搜索