Home >WeChat Applet >Mini Program Development >How to use action-sheet to pop up the bottom menu of WeChat applet

How to use action-sheet to pop up the bottom menu of WeChat applet

小云云
小云云Original
2017-12-11 09:26:234907browse

This article mainly introduces the WeChat applet to implement the action-sheet pop-up bottom menu function. It analyzes the usage skills of the action-sheet component pop-up menu in the form of examples, including element traversal, event response and attribute setting. I hope it can help. to everyone.

1. Effect display

##2. Key code

① index.wxml


<button type="default" bindtap="actionSheetTap">弹出action sheet</button>
<action-sheet hidden="{{actionSheetHidden}}" bindchange="actionSheetbindchange">
  <block wx:for-items="{{actionSheetItems}}" wx:key="{{txt}}">
    <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:&#39;Menu1&#39;,txt:&#39;菜单1&#39;},
   {bindtap:&#39;Menu2&#39;,txt:&#39;菜单2&#39;},
   {bindtap:&#39;Menu3&#39;,txt:&#39;菜单3&#39;}
  ],
  menu:&#39;&#39;
 },
 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
  })
 }
})

Have you learned it yet? I hope everyone has to help.

Related recommendations:

Introduction to how to set the bottom navigation column of WeChat Mini Program

About WeChat Mini Program click controls to modify the style Code example

Scrollable navigation effect at the top of WeChat applet

The above is the detailed content of How to use action-sheet to pop up the bottom menu of WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn