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