Vue data cannot be updated responsively after pushing
Open up space without new attributes
if ( > 0) { // var goodesMap = new Map() var temp_goodsList = [] var trandeProductList = ({ goodsList: [] }) for (var i = 0; i < ; i++) { for (var j = 0; j < ; j++) { if ([i].tradeNo == trandeProductList[j].trandeForm .tradeNo) { temp_goodsList.push(trandeProductList[j]) } } [i]["goodsList"] = temp_goodsList // ([i], ("goodsList")); // [i].push(goodsList) temp_goodsList = [] // () } // var s = [0].orderList[0]. // for (var i = 0; i < ; i++) // { // for (var j = 0; j < [i].; j++) { // ([i].goodsList[j].) // } // } }
How to update the content of responsive array and object
data: { // 1. Basic data type, string: directly modify data title:"vue", // 2. Array type: Use 7 mutants to modify ingredients: ['meat', 'fruit', 'cookies'], // 2-2: The content of the array is an object // ①: If it is to change an element in the object, [1].xxx // ②: If you modify the entire object content, you can also use 7 mutants to modify it. persons: [ { name: 'Vane', age: 38, color: 'red' }, { name: 'Fang', age: 27, color: 'blue' }, ], // 3. Object type // ①: If the original responsive data is modified, then // ②: If it is new responsive data, then this.$set(,'xxx','x') userInfo:{ name:"wangwu", age:19 } },
1-Update the basic data type (string)
="vue2" directly modify data
2-Update the array type
You cannot use it to modify data directly
Use 7 mutants to modify pop, push, shift, unshift, splice, sort, reverse. They have been remodeled in vue.
[1]="soup" // fail (1,1,"soup") // success
2-2: The content of the array is an object
1. Modify a certain property in the object:
[1].name="lisi"
2. Use mutant functions to modify as a whole:
(1,1,{name: 'zhangsan', age: 20, color: 'green'})
3. It is not possible to directly replace the array elements as a whole.
[1]={ name: 'zhangsan', age: 20, color: 'green' }
3-Object Type
1. If the original responsive data is modified, then
2. If responsive data is added, this.$set(,'xxx','x').
this.$set: The first parameter is the target object, the second parameter is the object's attribute, and the third parameter is the object's attribute value
Notice:
- ="Male" Uses directly added data, not responsive data, and will not appear in the vue debugging tool.
- It is just an ordinary attribute node, not a responsive attribute node
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.