routes: [
{
path: '/',
name: 'index',
component: index
},
{
path: '/sectionOne',
name: 'sectionOne',
component: sectionOne
}
]
现在的路由。 怎么配置 进入到'/djodqjd'的时候进入index
routes: [
{
path: '/',
name: 'index',
component: index
},
{
path: '/sectionOne',
name: 'sectionOne',
component: sectionOne
}
]
现在的路由。 怎么配置 进入到'/djodqjd'的时候进入index
在最后加一个,放到最后是因为优先级最低,前边的匹配不到才会进入默认的index.
{
path: '/',
name: 'index',
component: index
},
{
path: '/sectionOne',
name: 'sectionOne',
component: sectionOne
},
{
path: '/*',
component: index
}
题主可以这样来进行配置
{
path: '/',
name: 'index',
component: index
},
{
path: '/sectionOne',
name: 'sectionOne',
component: sectionOne
},
{
path: '/djodqjd',
component: Djodqjd,
redirect: '/index',
}
通过redirect,当进入路由djodqjd的时候,就直接重定向到index
你的意思是进入404页面吧,可以如下配置,输入路由表中不存在的路由,都会进入该404_index
组件页面,但是要放路由表中的最后面
{
path: '*',
component: 404_index
}
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答4.7k 阅读✓ 已解决
4 回答4.3k 阅读✓ 已解决