微信小程序?qū)崿F(xiàn)的點擊按鈕 彈出底部上拉菜單功能示例
更新時間:2018年12月20日 09:20:14 作者:CoKeny
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)的點擊按鈕 彈出底部上拉菜單功能,結(jié)合實例形式分析了action-sheet組件及事件響應簡單使用技巧,需要的朋友可以參考下
本文實例講述了微信小程序?qū)崿F(xiàn)的點擊按鈕 彈出底部上拉菜單功能。分享給大家供大家參考,具體如下:
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
})
}
})
運行效果(調(diào)試環(huán)境問題,顏色出現(xiàn)了偏差,效果湊合看~):

PS:關于微信小程序組件相關說明還可查看微信小程序組件說明表:http://tools.jb51.net/table/wx_component
希望本文所述對大家微信小程序開發(fā)有所幫助。

