vue-router路由懒加载的三种写法

1. 结合Vue的异步组件和Webpack的代码分析

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

2. SMD写法·

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

3. 在ES6中,我们可以有更加简单的写法来组织Vue异步组件和Webpack的代码分割(推荐使用)

const Home = () => import('../components/Home.js')

你可能感兴趣的:(vue,vue-router,vue.js,javascript,前端)