// 获取已发现的蓝牙设配
getBluetoothDevices() {
var that = this;
wx.getBluetoothDevices({
success(res) {
that.stopBluetoothDevicesDiscovery()
wx.hideLoading()
console.log(res.devices, '发现的蓝牙设配成功')
for (var key in res.devices) {
res.devices[key].active = false
}
that.setData({
lanyanlist: res.devices,
isbnt: true
})
},
fail(err) {
console.log(err, '发现的蓝牙设配失败')
},
complete(data) {
console.log(data, '发现的蓝牙设配完成')
}
})
},
//修改数据
addsuo(e) {
var that = this;
var index = e.currentTarget.dataset.index
var name = `lanyanlist[${index}].name`
this.setData({
[name]: 'chengwen'
})
},
lanyanlist数组 数据会丢失
// 模板传参
lanyanlist: [{
name: '蓝牙1',
deviceId: "71:00:8B:32:26:CC",
RSSI: -60
}, {
name: '蓝牙2',
deviceId: "71:00:8B:32:26:CC",
RSSI: -60
}, {
name: '蓝牙3',
deviceId: "71:00:8B:32:26:CC",
RSSI: -60
}, {
name: '蓝牙4',
deviceId: "71:00:8B:32:26:CC",
RSSI: -60
}],
//修改数据
addsuo(e) {
var that = this;
var index = e.currentTarget.dataset.index
var name = `lanyanlist[${index}].name`
this.setData({
[name]: 'chengwen'
})
},
这样子修改又没问题 是什么原因?
微信小程序开发问题解答
微信小程序开发者回答:
https://developers.weixin.qq.com/s/Rb10m8mn7F75
微信小程序开发者回答:
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
本文网址:http://www.91bianli.com/weixinxiaochengxu/7701.html