zoukankan      html  css  js  c++  java
  • 小程序API(1.20)操作菜单的使用方法

     

     

    <!--pages/index.wxml-->
    <view class='box'>
      <view class='title'>ActionSheet示例</view>
      <button type='primary' bindtap='showActionSheet'>显示ActionSheet</button>
      <view>你点击的菜单项下标是:{{tapIndex}}</view>
      <view>你点击的菜单项是:{{tapItem}}</view>
    </view>
    /* pages/index.wxss */
    
    button, view {
      margin: 20px;
    }
    // pages/index.js
    var myItemList = ['第一项', '第二项', '第三项', '第四项']//全局数组变量=菜单项
    Page({
      showActionSheet: function() {
        var that = this;
        wx.showActionSheet({ //调用API函数显示操作菜单
          itemList: myItemList, //操作菜单项列表
          itemColor: '#0000FF', //操作菜单项文字颜色
          success: function(res) {
            console.log(myItemList)
            that.setData({
              tapIndex: res.tapIndex, //点击的菜单序号
              tapItem: myItemList[res.tapIndex] //点击的菜单项
            })
          },
          fail: function(res) {
            that.setData({
              tapIndex: -1,
              tapItem: '取消'
            })
          },
          complete: function(res) {},
        })
      }
    })

    API函数wx.showActionSheet()的 使用方法

      wx.showActionSheet(Object object)用于显示操作菜单。其参数属性除了 success、fail和complete外,还包含:  

        

         success 的 参数属性 tapIndex 表 示 用户点击的按钮序号,该序号从上到下 排序,从0开始。

  • 相关阅读:
    hdoj_1016Prime Ring Problem
    毛玻璃
    HDOJ1175连连看
    const小结
    指向二维数组的指针
    关于对ACM OJ大数据递归栈溢出问题的解决方案
    Hessian的使用与介绍
    Tomcat调优
    ant使用
    ant使用
  • 原文地址:https://www.cnblogs.com/suitcases/p/14841468.html
Copyright © 2011-2022 走看看