1、更改数组中的值
paraList: [
{txt:'123',chose:false},
{txt:'1234',chose:false}
]
let choseChange = "paraList[" + index + "].chose"
this.setData({
[choseChange]: true,
numList: numList
})
可以改变数组中某一个特定下标的值
2、更改对象中的值
userInfo: { // 用户的验证信息
sex: '',
name: '',
phone: '',
code: '',
sexTxt:'请选择你的性别',
nameTxt:'名字不能为空',
phoneTxt: '手机号不能为空',
codeTxt: '获取验证码',
codeErrTxt:'验证码不能为空'
},
let userSex = "userInfo.sex"
this.setData({
[userSex]: '1'
})