npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wx-miniprogram-actionsheet

v1.0.7

Published

wechat miniprogram custom component actionsheet

Downloads

13

Readme

wx-miniprogram-actionsheet

微信小程序自定义组件——底部菜单ActionSheet

写这个自定义ActionSheet组件,和自定义modal一样,有些开放能力必须绑定在button上,而我们有时候又会有在底部上拉菜单中实现转发功能的需求,或者别的微信开放能力,小程序原生的ActionSheet依然无法实现,故此组件应运而生。

安装

1.使用npm安装

直接使用小程序开发工具自带的构建npm,请按下面几个步骤引入:

  • 确保项目目录下有package.json文件,已有的跳过这一步
$ npm init
  • 安装
$ npm i wx-miniprogram-actionsheet
  • 在小程序开发者工具中依次找到并点击工具->构建npm,构建完成后你的项目目录会多出一个miniprogram_npm目录,请确保项目设置已勾选使用npm模块

  • 在使用组件的页面配置json中使用

{
  "usingComponents": {
    "action-sheet": "wx-miniprogram-actionsheet"
  }
}

2.不使用任何构建工具的普通小程序安装

直接拷贝wx-miniprogram-actionsheet仓库中的miniprogram_dist目录下的代码到项目中的放组件的目录中去,之后使用方法和小程序自定义组件一样了。同样需要在页面配置json中声明:

{
  "usingComponents": {
    "action-sheet": "../components/mysheet/index"
  }
}

使用

wxml文件中

<action-sheet actionShow="{{showStatus}}" closeText="关闭" bind:actionHide="onActionHide">
  <!-- slot ActionSheet 菜单项 只能是button 或 navigator -->
  <navigator url="/pages/index/index">我是navigator: 回首页</navigator>
  <button bindtap="handleBtn">我是普通按钮</button>
  <button open-type="share">开放能力: 转发</button>
</action-sheet>

js文件中

// 只列出核心代码
Page({
  data: {
    actionStatus: false
  },
  onActionHide: function () {
    console.log('ActionSheet关闭了')
  }
})

菜单项写进<action-sheet></action-sheet>标签里即可,菜单项 只能是button 或 navigator。

演示效果

参数

| 属性 | 数据类型 | 说明 | 选项 | 默认值 | | :--------: | :------: | :----------------: | :--: | :----: | | actionShow | Boolean | 组件的初始显隐状态 | 必填 | — | | closeText | String | 取消按钮的文字 | 选填 | 取消 |

触发事件

| eventName | 说明 | | :--------: | :----------------------------------------------------------: | | actionHide | action-sheet组件被关闭时触发的事件,除了点关闭按钮会触发外,点其他按钮都会关闭组件,都会触发该事件,按需使用 |

示例Demo

微信小程序自定义组件使用示例整合