微信小程序 动态绑定事件并实现事件修改样式

前端之家收集整理的这篇文章主要介绍了微信小程序 动态绑定事件并实现事件修改样式前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@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
}
}

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)

@H_404_0@

wxss

.reportTypeScroll {
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;
}

@H_404_0@感谢阅读,希望能帮助到大家,谢谢大家对本站的支持

猜你在找的微信小程序相关文章