目錄
一、效果圖:
二、代碼
js:
wxml:
一、效果圖:
文章來源地址http://www.zghlxwxcb.cn/news/detail-516913.html
二、代碼
js:
Page({
data:{
hidden:false,
},
// 隱藏
yincang:function(e){
setTimeout(function () {
this.setData({
hidden: true
})
}.bind(this), )
},
// 顯示
xianshi:function(e){
setTimeout(function () {
this.setData({
hidden: false
})
}.bind(this), )
},
})
wxml:
<view style="text-align: center;">
<view hidden='{{hidden}}' >
<image mode='widthFix' src='https://gd-hbimg.huaban.com/f3b0ddffcf31f47a4bb6ed1cca127b4665a30a2f35598-fR8uq4'></image>
<button style="margin-top: 25rpx;" type="warn" bindtap='yincang'>隱藏</button>
</view>
<view wx:if="{{hidden}}">
<!-- <image mode='widthFix' src='https://gd-hbimg.huaban.com/8de549e728eff85248a619a845bc00409f277adf18b8d-zALOF3'></image> -->
<button style="margin-top: 25rpx;" wx:if="{{hidden}}" type="primary" bindtap='xianshi'>顯示</button>
</view>
</view>
文章來源:http://www.zghlxwxcb.cn/news/detail-516913.html
到了這里,關(guān)于微信小程序通過點擊按鈕控制元素隱藏與顯示的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!