正常監聽一個屬性的字段
<script>
window.custFormComponentMixin ={
data: function () {
return {"test":"helloWorld"};
},
watch:{
你的屬性:(a,v){
console.log("你的屬性發生改變了")
}
},
created:function(){
console.log("create");
},methods:{
testaaa:function(){alert(1)}
}
}
</script>
但是這樣寫的無法監聽一個多級對象的屬性
<script>
window.custFormComponentMixin ={
data: function () {
return {"test":"helloWorld"};
},
watch:{
你的屬性.子屬性.子屬性:(a,v){
console.log("你的屬性發生改變了")
}
},
created:function(){
console.log("create");
},methods:{
testaaa:function(){alert(1)}
}
}
</script>
屬性爲:你的屬性.子屬性.子屬性
例如:user.a.b.c
他就會報錯,怎麼處理呢?
<script>
window.custFormComponentMixin ={
data: function () {
return {"test":"helloWorld"};
},
watch:{
'data.glp_tsyw_obj.ssyq': {
handler: function() {
console.log("你的屬性發生改變了")
},
}
},
created:function(){
console.log("create");
},methods:{
testaaa:function(){alert(1)}
}
}
</script>