微信小程序wxml的显示和隐藏效果

mac2024-05-24  49

wxml: <view > <button class="{{showView?'show':'hide'}}" bindtap="change">{{showView?'隐藏':'显示'}}</button> <button class="{{showView?'hide':'show'}}" bindtap="change">{{showView?'隐藏':'显示'}}</button> </view> <view class="{{showView?'show':'hide'}}"> <text class="text">我是被显示被隐藏控件</text> </view> wxss: .hide{ display: none; } .show{ display: block; } js: Page({ data: { showView: true }, onLoad: function (options) { showView: (options.showView == "true" ? true : false) }, change: function () { var that = this; that.setData({ showView: (!that.data.showView) }) } })
最新回复(0)