The new key-value pair of the object in the vue project loses responsiveness

The new key-value pair of the object in the vue project loses responsiveness

Problem Description:

The existing data is as follows (data), how to add an attribute to each item as add, the value is "22", directly using the object method will cause the page to lose responsiveness, please see the second step:

data:[
{
id:1,
name:2,
age:30
},{
id:2,
name:3,
age:30
},
]

Solution:

Just copy and paste

this.$set(obj,"add","22")
this.$set()		就是语法,没啥解释的
obj			原来的对象,就是上面数据data里面的每一项
"add"		需要增加的键名,记得用 *“引号”* 包裹,否则会提示变量未定义
"22"		需要增加的键值,记得用 *“引号”* 包裹,否则会提示变量未定义

It’s more reassuring to explain. I like things that are out of the box. When I look at other people’s things, I often know where C is, but I don’t know where V is?
** So the above code, where you want to add, just go to V! **

Guess you like

Origin blog.csdn.net/m0_71585401/article/details/130240302