一、require.ensure()
require.ensuire(dependencies:String[],callback:function(require),errorCallback:function(error),chunkName:String)
const List = resolve =>{ require.ensuire([],()=>{ resolve(require('./list')) },'list') }
In the packing webpack when packaged as a whole routing will js file, the more routing component, the greater js file, the slower the load. Use require.ensure () to load the components will play a single js file. The following is each component, there is no custom name, it will be starting at 0 (when there are hash will be put md5).
Second, the router configuration, the following method may also be implemented on-demand loading, a component generating a js file.
{ path: '/home', name: 'home', component:resove => require(['@/components/home'],resolve) }
Third, the use import () loading assembly
const test1 = ()=>import('@/components/test1.vue')