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
})
posted @ 2019-01-03 15:46  Peter_Yang0942  阅读(561)  评论(0编辑  收藏  举报