如果ID不存在,如何将用户重定向到“ 404未找到”页面?
我有一条动态路线,如下所示:
const routes = [
{
path: '/',
component: Home
},
{
path: '/content',
component: DataTable
},
{
path: '/content/:NAS_ID', <----what if there's an NAS_ID that does not exist?
name: 'datadetail',
component: DataDetail
},
{
path: '/404',
component: NotFound
},
{
path: '*',
redirect: '/404'
}
];
如何为无效的NAS_ID编写导航保护?谢谢。