vue工程按业务路由打包,页面只加载对应资源
修改路由表:src/router/index.js
import Vue from 'vue';
import Router from 'vue-router';
// 主要写法如下
const Test = r => require.ensure([], () => r(require('@/components/test/test.vue')), 'test');
const routes = [{
path: '/',
redirect: '/error/404'
},
{
path: '/test',
name: 'test',
component: Test
}];
export default new Router({
mode: 'history',
base: '/',
routes: routes
})