UPDATE:
abcd
abc
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
img: 'http://xiaozhangzaici.com/a.jpg',
hidden: false
},
binderrorimg: function (e) {
this.setData({
hidden: true
})
}
})
UPDATE2:解决一隐藏全部隐藏的问题
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
array: [
{ src: 'http://xiaozhangzaici.com/a.jpg'},
{ src: 'https://www.baidu.com/img/bd_logo1.png'}
]
},
binderrorimg: function (e) {
console.log(e.currentTarget.dataset.abc);
var brokenImgIndex = e.currentTarget.dataset.abc;
for (var i = 0; i < this.data.array.length; i++) {
if (i == brokenImgIndex) {
console.log(i);
this.setData({
['array[' + i + '].is_not_show']: true,
})
}
}
}
})
abc
.notshow {
display: none;
}