小程序可重复点击的按钮(false和true)
代码如下wxml:<view class='{{san?"v1":"v2"}}' bindtap="selectList"></view>css:.v1 { width: 100rpx; height: 100rpx; background: red; border-radius: 50rpx;}.v2 { width: 100rpx; height: 100rpx; background: gray; border-radius: 50rpx;}
js:
Page({ data: { san: true, i: 1, //变量 },// 声明一个变量,并判断这个变量 selectList: function () { var that = this; console.log(that.data.i, "i") if (that.data.i == 1) { that.data.i = 2, that.setData({ san: false, }) } else { that.data.i = 1, that.setData({ san: true, }) } console.log(that.data.i, "i2222") },})声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

