wx-tool

1.1.6 • Public • Published

wx-tool

微信小程序工具类集合,有效提高开发时间和效率!

另推荐云函数合集模板

重要:版本要求

  1. 小程序基础库版本 2.2.3 或以上
  2. 开发者工具 1.02.1808300 或以上开始,小程序支持使用 npm 安装第三方包。

使用微信开发者工具打开此项目,然后在项目根目录下运行:

npm install --production

安装好依赖包之后,点击工具顶部菜单栏的详情:

image

勾选“使用 npm 模块”选项:

image

最后点击开发者工具中的菜单栏:工具 --> 构建 npm 即可运行。

image

1.快速开始

    $ npm i wx-tool --save

2.按需引入

    var {
        showModal
    } = require('wx-tool')

3.使用例子

属性 类型 默认值 必填 说明
title string 提示的标题
content string 提示的内容
showCancel string true 是否显示取消按钮
cancelText string 取消 取消按钮的文字,默认为"取消",最多 4 个字符
cancelColor string #000000 取消按钮的文字颜色,默认为"#000000"
confirmText string 确定 确定按钮的文字,默认为"确定",最多 4 个字符
confirmColor string #00aaff 确定按钮的文字颜色,默认为"#00aaff"
    // 等同于 wx.showModal
    // 返回Promise
    showModal({
        title: `提示`,
        content: '支付成功',
        showCancel: false
    }).then((res)=>{
        console.log(res)
    })


    // 也可以使用 async/await
    async test(){
        try {
            let {
                confirm
            } = await showModal({
                title: '提示',
                content: `是否确认收货?`
            })
            if(confirm) {
                // 用户点击确认


                //你的代码....
            }
        } catch (error) {
            console.log(error)
        }
    }

API

Package Sidebar

Install

npm i wx-tool

Weekly Downloads

0

Version

1.1.6

License

MIT

Unpacked Size

111 kB

Total Files

47

Last publish

Collaborators

  • sea_lx