this.setData设置key出现变量的解决方式


简单变量直接可用引号 ‘a.b.c’ 。

访问数组下标使用[ ]时用到变量,可使用es6新特性

示例:

let index = this.data.messageList.findIndex(item => this.data.dialog.code === item.code);
this.setData({
  'dialog.show': false,
  ['messageList['+index+'].isread']: true
});
this.setData({
   ['messageList['+e.currentTarget.dataset.index+'].isread']: true
0

【this.setData设置key出现变量的解决方式隶属于分类:

它起初由本站用户:刘欣Eden于8个月前 创建。

该内容的链接是:

目录