问题遇到的现象和发生背景
微信小程序开发,用setData()赋值变量数组,失败!无报错 就是复制不上
遇到的现象和发生背景,请写出第一个错误信息
无报错,想要赋值的数组 数据不改变。
用代码块功能插入代码,请勿粘贴截图。 不用代码块回答率下降 50%
<view style="padding: 100rpx 0 30rpx 0;">
<text class="title">选择你要推广的平台</text>
</view>
<view class="mast">
<view wx:for="{{menu_info}}" class="{{item.class}}" bindtap="onXzPt" data-index="{{item.id}}">
{{item.name}}
</view>
</view>
data: {
menu_info:[
{id:0,name: "抖音",class: "item",select: 1},
{id:1,name: "快手",class: "item_f",select: 0},
{id:2,name: "视频号",class: "item_f",select: 0},
{id:3,name: "美团",class: "item_f",select: 0},
{id:4,name: "小红书",class: "item_f",select: 0}
]
},
onXzPt:function (e) {
var that = this
let oncklik = e.currentTarget.dataset.index
for (var i in that.data.menu_info){
let menuid = that.data.menu_info[i].id
var newclass = "that.data.menu_info["+i+"].class"
if(menuid == oncklik){
that.setData({
[newclass] : 'item'
})
console.log(newclass)
console.log(that.data.menu_info[i].class)
}
else{
}
}
},
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/442249896076190.png "#left")
运行结果及详细报错内容
that.data.menu_info[3].class
pt.js? [sm]:27 item_f
我的解答思路和尝试过的方法,不写自己思路的,回答率下降 60%
所有的办法都试过了,能想的能查的都用过了,还是不行,请帮助。