微信小程序開發(fā)文檔
/ wxapp操作反饋上拉菜單 action-sheet
wxapp操作反饋上拉菜單 action-sheet
action-sheet
上拉菜單,從屏幕底部出現(xiàn)的菜單表。
action-sheet-item
底部菜單表的子選項(xiàng)。
action-sheet-cancel
底部菜單表的取消按鈕,和action-sheet-item的區(qū)別是,點(diǎn)擊它會觸發(fā)action-sheet的change事件,并且外觀上會同它上面的內(nèi)容間隔開來。
示例代碼:
<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>
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)