我正在使用 vue-router,我们正在使用大量有效负载查询,例如 /Foo/?type=225 我将如何将它与粗体 url 的嵌套组件匹配?
是这样的吗?
const Foo = { template: '<div>Foo<router-view></router-view></div>' }
const Bar = { template: '<div>Bar</div>' }
const router = new VueRouter({
mode: 'history',
routes: [
{
path: '/foo',
component: Foo,
children: [
{
path: '',
component: Bar,
query: { type: '225' }
}
]
}
]
})
上面的代码不能正常工作,我希望它只匹配 type=225 但它甚至匹配 type=1 等等。
最佳答案
我建议您在 View 文件中执行该解决方案。
<Bar v-if="$route.query.type == 225" />
关于javascript - vue-router匹配查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48165522/