路由main.js
{
name:'hotel',
path:'/hotel/:id',
component:Hotel
}
list.vue页面
<router-link :to="{path:'/hotel/'+item.id}">
是这样子的,我想把item.id传给hotel.vue页面,。点击url会跳转到http://localhost:8080/#/hotel/1
我在hotel.vue页面中
mounted(){
console.log(this.$vm.$route.params) //
//我想在这里得到参数,会报下面这个错误
//$route is not defined
}
得不到参数?怎么做
另外 如果改成下面<router-link :to="{path:'/hotel',params:{id:item.id}}">
这样,http://localhost:8080/#/hotel
不知道为什么连后缀都没了
<router-link :to="{path:'/hotel',params:{id:item.id}}">