會沒有指定 query ( 如 /products?type=food ) 只進入 /products
使其固定帶上 query 方式如下
{
name: 'products',
path: `${rootPath}/products`,
component: () => import(/* webpackChunkName: "courses" */ '../pages/products/').then(m => m.default || m),
beforeEnter: (to, from, next) => {
if (!to.query.type) {
next({
path: to.path,
query: { type: 'food' }
})
}
next()
}
},
沒有留言:
張貼留言