微信小程序 动态绑定 style 样式 和class
发表时间:2020-9-23
发布人:葵宇科技
浏览次数:132
<view class="changeImageView" style="display:{{displayPhoto}}" >
<view class="operbtn">测试</view>
</view>
<view class="section section_gap">
<view class="section__input">
<button class="operBtn {{select==1?'activeClass':''}}" bindtap='selectBtn' data-num="1" >选项1</button>
<button class="operBtn {{select==2?'activeClass':''}}" bindtap='selectBtn' data-num="2" >选项2</button>
</view>
</view>
Page({
data: {
displayPhoto:'none',
select:1
},
selectBtn(event){
this.setData({
select: event.currentTarget.dataset.num
})
}
});