1.子组件给父组件传值
父组件:
<router-view @getShopCode='getShopCode'>
methods:{
getShopCode(value){
conso.log(value);
}
}
子组件:
methods:{
goShopList(value){
this.emit('getShopCode',value);
this.router.push({name:'shopList'});
}
}
2.父组件发生变化导致子组件变化
父组件:
// inputValue为传递给子组件的值
<router-view :inputValue='inputValue'></router-view>
子组件:
watch:{
inputValue:function(value){
console.log(value)
}
}
评论区