WeChat applet's method of changing a certain value in an array or a certain value in an object

1. Change the values ​​in the array

paraList: [
	{
    
    txt:'123',chose:false},
	{
    
    txt:'1234',chose:false}
]

let choseChange = "paraList[" + index + "].chose"
this.setData({
    
    
	[choseChange]: true
})

Note: You do not need to write this.data for the string of the selected array. !!!

You can change the value of a specific subscript in the array

2. Change the value in the object

navbarData: {
    
    
    isfixed: false,
    iswhite: false, //icon color
    showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
    title: '客户列表', //导航栏 中间的标题
    backgroundcolor: '#fff',
    isintercept: false, //返回拦截
},

let title = 'navbarData.title'
this.setData({
    
    
	[title]: '组员客户',
})

Guess you like

Origin blog.csdn.net/ws19900201/article/details/108641867