huoxiangdong / Blog

学习记录
0 stars 0 forks source link

Vue & Webpack 懒加载 #52

Open huoxiangdong opened 6 years ago

huoxiangdong commented 6 years ago

// 1
resolve => import('@/views/layout/report/main').then(resolve)
// 2
resolve => {  require(['@/views/layout/report/main'], resolve) } // 这里是你的模块 不用import去引入了
// 3 使用
resolve => require.ensure([], () => resolve(require('@/views/layout/report/main')), 'report')
huoxiangdong commented 6 years ago
huoxiangdong commented 6 years ago

dynamic import


// 1
npm i -D babel-plugin-syntax-dynamic-import
// 2 
在.babelrc文件的plungins中添加"syntax-dynamic-import"
huoxiangdong commented 6 years ago

// 直接使用
() => import("@/views/evolution/index.js")