微信小程序之改变数组中某值,对象中某值的方法

1、更改数组中的值

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

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

注意:选定数组的字符串不用写 this.data. !!!

可以改变数组中某一个特定下标的值

2、更改对象中的值

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

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

猜你喜欢

转载自blog.csdn.net/ws19900201/article/details/108641867
今日推荐