微信小程序点击按钮 弹出底部上拉菜单
//index.wxml <button type="default" bindtap="actionSheetTap">弹出action sheet</button> <action-sheet hidden="{{actionSheetHidden}}" bindchange="actionSheetbindchange"> <block wx:for-items="{{actionSheetItems}}"> <action-sheet-item bindtap="bind{{item.bindtap}}">{{item.txt}}</action-sheet-item> </block> <action-sheet-cancel class="cancel">取消</action-sheet-cancel> </action-sheet> <view> 提示:您选择了菜单{{menu}} </view>
//index.js Page({ data:{ // text:"这是一个页面" actionSheetHidden:true, actionSheetItems:[ {bindtap:\'Menu1\',txt:\'菜单1\'}, {bindtap:\'Menu2\',txt:\'菜单2\'}, {bindtap:\'Menu3\',txt:\'菜单3\'} ], menu:\'\' }, actionSheetTap:function(){ this.setData({ actionSheetHidden:!this.data.actionSheetHidden }) }, actionSheetbindchange:function(){ this.setData({ actionSheetHidden:!this.data.actionSheetHidden }) }, bindMenu1:function(){ this.setData({ menu:1, actionSheetHidden:!this.data.actionSheetHidden }) }, bindMenu2:function(){ this.setData({ menu:2, actionSheetHidden:!this.data.actionSheetHidden }) }, bindMenu3:function(){ this.setData({ menu:3, actionSheetHidden:!this.data.actionSheetHidden }) } })
版权声明:本文为panlaixing原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。