最近自己试着用VUE框架进行编写,在路由嵌套的时候准备直接跳转到最后一个路由
例:http://localhost:8081/#/zh-CN/home
直接跳转到home界面,但是没有写component,导致一直界面不显示
所以进行查询,发现 <router-view/> 是必须的
再不想创建一个单独的VUE文件时,可以用以下代码实现
component: {render: (e) => e("router-view")}
const routes = [
{
path:"*",
redirect:"/zh/home"
},
{
path: '/',
redirect: "/zh-CN/home",
component: Main,
children: [
{
path: "zh-CN",
name: "zh-CN",
redirect: "/zh-CN/home",
component: {render: (e) => e("router-view")},
children: [
{
path: 'home',
name: "home",
component: Home
}
]
}
]
}
]