【发布时间】:2018-08-23 15:25:09
【问题描述】:
我是 Vue 的新手,一直在做一个演示项目,我似乎无法理解带有查询参数的路由是如何工作的。我注意到他们在文档中推荐了router.push({ path: 'register', query: { plan: 'private' }}),这会产生/register?plan=private。
有没有办法用嵌套路由做到这一点?
我正在尝试将其作为 BookAppointment 组件的 URL:/physicians/?appt_id=12345&npi=123456789。如果有更好的方法可以做到这一点,我愿意接受建议。提前致谢。
路由器/index.js
const router = new VueRouter({
routes: [
{ path: '/physicians/', component: PhysicianLanding,
children: [
{
// PhysicianProfile
path: 'profile/:url',
component: PhysicianProfile
},
{
// BookAppointment has 3 different progress steps to get to
// the confirm page
path: '',
query: { appt_id: '12345', npi: '123456789'},
component: BookAppointment
}
]
}
]
})
【问题讨论】:
标签: javascript vue.js vue-component vue-router