vue路由传参和子组件接收值
1、父组件路由传参this.$router.push({path:'/roomDetail',query:{num:dd}})2、子组件接收created () {...
·
1、父组件路由传参
this.$router.push({
path:'/roomDetail',
query:{
num:dd
}
})
2、子组件接收
created () {
this.routerQuery = this.$route.query.num;
},
关键部分代码
watch : {
routerQuery: function (newValue, oldValue) {
this.findPositionByRoom(newValue);
},
$route(to, from) {
console.log(to.query.num)
if(to.query.num != undefined){
this.findPositionByRoom(to.query.num);
}
}
},
以上jingzu
更多推荐
已为社区贡献9条内容
所有评论(0)