微信小程序实现的点击按钮 弹出底部上拉菜单功能示例
更新时间:2018年12月20日 09:20:14 作者:CoKeny
这篇文章主要介绍了微信小程序实现的点击按钮 弹出底部上拉菜单功能,结合实例形式分析了action-sheet组件及事件响应简单使用技巧,需要的朋友可以参考下
本文实例讲述了微信小程序实现的点击按钮 弹出底部上拉菜单功能。分享给大家供大家参考,具体如下:
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 }) } })
运行效果(调试环境问题,颜色出现了偏差,效果凑合看~):
PS:关于微信小程序组件相关说明还可查看微信小程序组件说明表:http://tools.jb51.net/table/wx_component
希望本文所述对大家微信小程序开发有所帮助。
相关文章
详解微信小程序开发—你期待的分享功能来了,微信小程序序新增5大功能
微信小程序在12月21日发布了新版本的开发工具,并在官网公布新增分享、模板消息、客服消息、扫一扫、带参数二维码功能。2016-12-12
最新评论