In some cases, sub-assemblies directly modify the parent component coming from prop 对象
the property of sync problems.
For example, the parent component pass over an object checkBoxObj
:
checkBoxObj:{
checked: false
}
The checked
binding by v-model to sub-assemblies checkbox, then click the checkbox, trying to change the checked
values, but sometimes find the opposite checkbox is checked and checked, that is, the problem is not synchronized.
(Try to) solution
The prop's checkBoxObj
value is assigned to a value of the data checkBoxData
,
this.checkBoxData = this.checkBoxObj;
Because it is a direct assignment, there are also references to the relationship, modify checkBoxData
the checked
equivalent modify checkBoxObj
the checked
. So this bug does not occur.
Then simply edit the checked property value checkBoxData, do not directly modify the value prop pass over.