用const定义了checked值为什么会变?
看下图用const定义了checked值为什么会变? [图片] [视频] [图片] 下面是代码 const haha = getApp().globalData.abc123
Page({
showModal(e) {
const yiyi = haha
console.log('haha值:',haha)
console.log('yiyi值:',yiyi)
this.setData({
checkbox: yiyi,
modalName: e.currentTarget.dataset.target
})
},
hideModal(e) {
this.setData({
modalName: null
})
},
ChooseCheckbox(e) {
let items = this.data.checkbox;
let values = e.currentTarget.dataset.value;
for (let i = 0, lenI = items.length; i < lenI; ++i) {
if (items[i].value == values) {
items[i].checked = !items[i].checked;
break
}
}
this.setData({
checkbox: items
})
}
}) 下面是app.js保存的值 App({
globalData: {
abc123: [{
value: 0,
name: 200,
checked: false,
hot: true,
}, {
value: 1,
name: 500,
checked: false,
hot: true,
}, {
value: 2,
name: 1000,
checked: false,
hot: true,
}, {
value: 3,
name: 2000,
checked: false,
hot: true,
}, {
value: 4,
name: 5000,
checked: false,
hot: true,
}, {
value: 5,
name: 10000,
checked: false,
hot: true,
}],
},
})