SoFunction
Updated on 2025-04-04

Vue child component listens for changes in parent component value

Children's components listen for changes in parent component value

Watch to listen for changes in parent component value in child components

// Subcomponentsprops: ["a"],
    watch: {
        a(oldValue, newValue) {
            // oldValue  a            // newValue a new value        }
    }

The child component listens to the parent component's values ​​to update data synchronously

Subcomponents

props : [“data”],

Subcomponent monitoring

    watch:{
    data : (n ,o) => {//Arrow function Otherwise this change will occur        ()
         = 
      }
 }

The above is personal experience. I hope you can give you a reference and I hope you can support me more.