Computed using realized and watch variables change parent component sub-assemblies monitor

In vue project application components simply commonplace, but one level of nesting components there will be some problems, such as changes in the value of the parent component sub-assembly will not lead to change, this time you need to monitor sub-components of the initiative changes in the parent component
This time you need to use computed this property, pay attention to listen variables can not be declared in the data in there, and then bound to pass on the child component
computed:{
    lists:function(){
      return this.$store.getters.isShow.list 
    },
}
- If you need to change the value of listeners in their own assembly, use watch, as long as the value change will trigger there's handler function, this value can be declared in the data
watch:{
    index:{
      handler(index){
          console.log(index)
      }
    }
  }

I have to say this is really good with hhh

 

Guess you like

Origin www.cnblogs.com/fdd-111/p/11839892.html