refactor(router): 优化路由生成逻辑和导航组件

- 修改路由生成逻辑,使用 name 作为 path,解决 path 未定义问题- 更新 sliderNav 组件中的路由跳转逻辑,使用 path 方式跳转
- 优化 url 参数处理,支持查询字符串
-调整路由配置模板,统一格式
This commit is contained in:
aixianling
2024-12-23 10:20:19 +08:00
parent 4ead05b251
commit 4684952973
2 changed files with 8 additions and 9 deletions

View File

@@ -53,9 +53,9 @@ const createRoutes = (config = {}) => {
{path: '/v', name: 'Home', component: () => import('../views/home'), children: [
${routes.map(e => {
// 解构每个路由的属性,用于生成路由配置
const {name, label, path, esm} = e
const {name, label, esm} = e
// 生成单个路由配置的字符串表示
return `{name:"${name}",label:"${label}",path:"${path}",component:()=>import("../${esm}")}`
return `{name:"${name}",label:"${label}",path:"${name}",component:()=>import("../${esm}")}`
}).join(',\n')}
]},
{path: '/', name: "init"},