Vue.js vue路由器将参数路由到组件属性?
我认为这会奏效:Vue.js vue路由器将参数路由到组件属性?,vue.js,vuejs2,vue-router,Vue.js,Vuejs2,Vue Router,我认为这会奏效: { path: '/course/:id', component: Course.extend({ props: { course: params.id } }) }, 遗憾的是,它并没有那么简单(它也不是id)。我该怎么做?(我刚上了一门关于vue的课程,简直不敢相信我记不起来了)因为在中,你必须在路线中设置道具选项,请参见下面的代码以了解它: const User = { props: ['id'], template: '<div>U
{ path: '/course/:id', component: Course.extend({
props: { course: params.id }
}) },
遗憾的是,它并没有那么简单(它也不是id
)。我该怎么做?(我刚上了一门关于vue的课程,简直不敢相信我记不起来了)因为在中,你必须在路线中设置道具
选项,请参见下面的代码以了解它:
const User = {
props: ['id'],
template: '<div>User {{ id }}</div>'
}
const router = new VueRouter({
routes: [
{ path: '/user/:id', component: User, props: true }
]
})
const用户={
道具:['id'],
模板:“用户{{id}}”
}
常量路由器=新的VueRouter({
路线:[
{path:'/user/:id',component:user,props:true}
]
})