Vue 路由懒加载

Vue项目中实现路由按需加载(路由懒加载)的3中方式:

1. vue异步组件
2. es6提案的import()
3. webpack的require.ensure()
一、Vue异步组件技术:
    {
        path: '/home',
        name: 'Home',
        component: resolve => reqire(['path路径'], resolve)
    }
二、es6提案的import()
const Home = () => import('path路径')
三、webpack提供的require.ensure() { path:
'/home', name: 'Home', component: r => require.ensure([],() => r(require('path路径')), 'demo') }

 

posted @ 2020-04-14 17:33  ZJTL  阅读(213)  评论(0编辑  收藏  举报