0
我只是想用路由器PARAMS一個基本功能,我得到未定義router.paramsVuejs router.params不確定
我的模板
<div id="app><template id="image-capture">
<div class="row" >
<router-link :to="{ path: 'vc/'+item.id}" class="btn btn-primary"> ACCEPT</router-link>
</div>
</template></div>
現在我的URL看起來像這樣http://localhost/cams-web/#/vc/3
const ic = {
template: '#image-capture' ,
}
const vc = {
template: '#video-capture' ,
mounted() {
this.init()
},
methods: {
init() {
console.log(router); //returns object
console.log(router.params); //undefined..
},
}
}
const routes = [
{ path: '/ic', component: ic},
{ path: '/vc/:id', component: vc}
]
const router = new VueRouter({
routes
})
new Vue({
router,
}).$mount('#app')
哈..感謝這麼多...我試圖「this.route」..當$路線未定義時從來沒有得到這個線索$ route .. –
謝謝,我試圖訪問此。$路由器它返回一個不同的對象。 – tomhughes