@H_404_0@
微信小程序 动态绑定事件并实现事件修改样式
@H_404_0@
实例代码
@H_404_0@
wxml
@H_301_13@
@H_404_0@js
var pageObject = {
data: {
reportTypeList: reportTypeList,num: 0,toLeftNum: 0,itemWidth: 150
}
}
@H_404_0@data: {
reportTypeList: reportTypeList,num: 0,toLeftNum: 0,itemWidth: 150
}
}
for (var i = 0; i < reportTypeList.length; i++) {
(function (item) {
pageObject['bind' + item.id] = function (e) {
var id = parseInt(e.currentTarget.dataset.typeid)
this.setData({
currentId: id
})
}
})(reportTypeList[i])
}
Page(pageObject)
wxss
.reportTypeScroll {
margin: 40px 0px 20px 0px;
white-space: nowrap;
display: flex;
}
@H_404_0@感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!margin: 40px 0px 20px 0px;
white-space: nowrap;
display: flex;
}
.clickSel {
color: red;
}
.removeSel {
color: black;
}
text {
height: 150rpx;
display: inline-block;
text-align: center;
}