1.子組件給父組件傳值 父組件: <router-view @getShopCode='getShopCode'></router-view> 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) } }