定义了映射理由
router.map({
'/router-new/:classId/': { component: rountNew,name:'router-new',},
'/router-video/:classId': { component: rountVideo ,name:'router-video', },
'/router-know/:classId': { component: rountKnow,name:'router-know', },
'/router-zixun/:classId': { component: rountZixun,name:'router-zixun', },
'/router-common/:classId': { component: rountCommon,name:'router-common', },
'/router-video-class/:classId': { component: rountVideoClass, name:'router-video-class', },
'/router-recommend/:classId': { component: rountRecommend, name:'router-recommend' },
});
在定义默认路径的时候怎么写都不对
router.redirect({
'/': '/router-new/',
})
这里应该怎么写才能匹配到定义的路由里面
该回答引用GPTᴼᴾᴱᴺᴬᴵ
在 Vue Router 中,如果想要将默认路径重定向到某个特定的路由中,需要使用 router.redirect 方法,例如:
router.map({
'/router-new/:classId/': { component: rountNew, name: 'router-new' },
// ...
});
router.redirect({
'*': '/router-new/1', // 将默认路径重定向到 /router-new/1 路径
});
上述代码中的 router.redirect 用来匹配其他未定义的路径,并将其重定向到 /router-new/1 这个默认路径中。其中,* 表示匹配所有未定义路径,也就是默认路径。
需要注意的是,这里的 classId 参数是必填的,应该根据实际情况进行设置。比如上述代码中的路径 /router-new/:classId/,其中的 :classId 表示参数,匹配的具体值可以在使用时通过 $route.params.classId 获取,因此需要根据具体情况设置正确的参数值。
希望这些信息能够对你有所帮助。