码迷,mamicode.com
首页 > 编程语言 > 详细

wepy根据下标对数组中的某个对象的元素进行赋值

时间:2020-04-22 18:09:52      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:bsp   strong   art   nbsp   function   小程序   dex   com   赋值   

1 //单选
2 select: function (e) {
3     let index = e.currentTarget.dataset.index;                
4     let staffList = this.staffList;
5     let newli = ‘staffList[‘ + index + ‘].checked‘;
6     this[newli] = !this.staffList[index].checked;
7 }

 

 

上述代码取自    https://www.cnblogs.com/dreamstartplace/p/12202465.html   功能。

由于在小程序中赋值是   this.setData({    [newli] = !this.staffList[index].checked       })      这样的,由于项目的变动,需要将代码放在wepy框架中,而在wepy动态修改数据不用setData,直接赋值就可以了,但是一定要注意在这里是   this[newli]     而不是    this.[newli]     (千万记住中间没有点“.”)

              

           

wepy根据下标对数组中的某个对象的元素进行赋值

标签:bsp   strong   art   nbsp   function   小程序   dex   com   赋值   

原文地址:https://www.cnblogs.com/dreamstartplace/p/12753838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!