Home  >  Article  >  Web Front-end  >  How to pop up the bottom menu in WeChat mini program

How to pop up the bottom menu in WeChat mini program

亚连
亚连Original
2018-06-21 17:45:473700browse

This article mainly introduces the WeChat applet to implement the action-sheet pop-up bottom menu function, and analyzes the usage skills of the action-sheet component pop-up menu in the form of examples, including element traversal, event response, property setting and other operation methods, and The source code is attached for readers to download and refer to. Friends in need can refer to

. This article describes the example of WeChat applet implementing the action-sheet pop-up bottom menu function. Share it with everyone for your reference, as follows:

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
  })
 }
})

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Use angular to write Message components

How to implement component communication in vue-cli

What should we pay attention to when optimizing Vue projects?

Developed using modular approach in vuejs

The above is the detailed content of How to pop up the bottom menu in WeChat mini program. 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