vue中添加动态路由
src/router/index.js
```
import Vue from 'vue';
import Router from 'vue-router';
import HelloWorld from '@/components/page/BaseTable.vue'
import VueRouter from 'vue-router';
Vue.use(Router);
const constantRoutes = [
{
path: '/table',
component: HelloWorld,
meta: { title: '基础表格' }
}
]
const createRouter = () => new VueRouter({
mode:'hash',
base:process.env.BASE_URL,
routes: constantRoutes
})
const router = createRouter()
const routeObj =
{
path: '/form',
component: () => import(/* webpackChunkName: "table" */ '../components/page/BaseForm.vue'),
meta: { title: '基础表单' }
}
router.addRoute(routeObj)
const routeObj1 =
{
path: '/test',
component: () => import(/* webpackChunkName: "table" */ '../components/page/BaseForm.vue'),
meta: { title: '基础表单' }
}
router.addRoute(routeObj1)
export default router
```