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)
     }
  }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-07
  • 2021-08-16
  • 2021-07-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-18
  • 2021-09-10
  • 2022-12-23
相关资源
相似解决方案