微信小程序 action-sheet 反馈上拉菜单简单实例
程序员文章站
2023-10-27 22:46:16
微信小程序 action-sheet 反馈上拉菜单简单实例
看下实现效果图:
js
var items = ['item1', 'item2', 'i...
微信小程序 action-sheet 反馈上拉菜单简单实例
看下实现效果图:
js
var items = ['item1', 'item2', 'item3', 'item4'] var pageobject = { data: { actionsheethidden: true, actionsheetitems: items }, actionsheettap: function (e) { this.setdata({ actionsheethidden: !this.data.actionsheethidden }) }, actionsheetchange: function (e) { this.setdata({ actionsheethidden: !this.data.actionsheethidden }) } } for (var i = 0; i < items.length; ++i) { (function (itemname) { pageobject['bind' + itemname] = function (e) { console.log('click' + itemname, e) } })(items[i]) } page(pageobject)
wxml
<button type="default" bindtap="actionsheettap">弹出action sheet</button> <action-sheet hidden="{{actionsheethidden}}" bindchange="actionsheetchange"> <block wx:for-items="{{actionsheetitems}}"> <action-sheet-item class="item" bindtap="bind{{item}}">{{item}}</action-sheet-item> </block> <action-sheet-cancel class="cancel">取消</action-sheet-cancel> </action-sheet>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!