pageData is an object, passed from my parents, and I received pageData, through props in the child component. I want to use watch to listen for changes in the properties in the pageData object, and then assign a value to newpageData.
but normal snooping pageData, doesn"t trigger at all. After changing it to deep surveillance. Console.log (newval) can listen for the latest value of pageData. Then I made a mistake when I tried to assign a value to this.newpageData.
* * Error in callback for watcher "pageData"
newpageData is not defined**
is there any way to solve this problem?
props:["pageData"],
data(){
return{
newpageData:null
}
},
watch:{
pageData:{
handler: function (newval, oldVal) {
console.log(newval)
this.newpageData=newval;
},
deep: true
}
}