一个开关的按钮。我想做成一个开状态下点击之后显示关。关状态下再点一下显示开
.js
page({
data:{
isopen:true,
state:“开”
},
buttontap:function(){
if(this.data.isopen){
this.setData({
state:"关"
})
}else{
state:"开"
}
this.data.isopen = !this.data.isopen
.wxml
<button type="primary" bindtap="buttontap">{{state}}</button>