js数组对象中添加属性和属性值

原数组格式:
在这里插入图片描述

向数组对象中添加属性和属性值:

let i = 0;
//this.templateRuleData[0].dropDownOptionList 为数组
this.templateRuleData[0].dropDownOptionList.forEach(item => {
	item.value = i++;
});

添加属性后数组格式:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42653522/article/details/106091134