点击关闭再点击显示的功能应该用什么去写,大神解答下!!
代码如下:
/----------wxml------------/
<view class=“container”>
<button bindtap=“change” >点击切换</button>
<view class=‘{{index==“true”?“hide”:“present”}}’ style=“background-color:red;width:200rpx;height:200rpx;margin:20px 0 30px 0;”></view>
/-----------wxss-----------/
.hide{display:none}
.present{display:block}
/-----------js---------------/
var app = getApp()
Page({
data: {
index:‘false’
},
change:function(e){
if(this.data.index==‘false’){
this.setData({index:‘true’})
}else{
console.log(this.data.index);
this.setData({index:‘false’})
}
}
})
截图:
一、刷新
二、点击关毕
三、再点击就出不来?怎么回事,求教大神

