在nuxtconfig.js里面router配置
router: {
mode: "history",
extendRoutes(routes, resolve) {
let newRouter = [];
// 路由别名
aliasList.map((item) => {
const index = routes.findIndex(route => ''+route.name === ''+item.name)
routes[index] = {
...routes[index],
alias:item.alias
}
})
// 新增路由
increaseRouter.map(item => {
let obj = {
...item,
name: item.name,
path: item.path,
component: resolve(item.pathName),
chunkName: item.name
};
newRouter.push(obj);
});
routes.push(...newRouter);
}
},
本以为动态路由静态的标识只能在前面,后面都是动态参数,结果打印的结果让人惊讶,动态参数:sub_name后面的-cj成为一个静态参数
{
// 中级会计子栏目-备考资料-二级
name: "sub_channel-junior-exam_share3",
path: "/bkzl-:sub_name-zj-:cate_id-:websiteId-:subcate_id/",
pathName: "@/pages/sub_channel/column_template.vue"
},