# smart-wx-utils

> 小程序工具库，最低兼容微信基础库版本2.1.0

Latest version **0.0.2-alpha-1** (published 2019-09-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install smart-wx-utils
pnpm add smart-wx-utils
yarn add smart-wx-utils
bun add smart-wx-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2-alpha-1 |
| Published | 2019-09-27 |
| First published | 2019-09-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 40.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | YantaoLu |
| Maintainers | yantaolu |
| Keywords | 小程序, 工具库 |

## Links

- npm: https://www.npmjs.com/package/smart-wx-utils
- npm.io page: https://npm.io/package/smart-wx-utils

## Recent versions

- 0.0.2-alpha-1 (latest) — 2019-09-27
- 0.0.2-alpha — 2019-09-27
- 0.0.1-alpha — 2019-09-27
- 0.0.1 — 2019-09-27

## README

## smart-wx-utils

> 提供小程序API及其他通用类型工具函数库，简化开发过程中原生API繁琐的传参及回调形式

> 计划提供axios式的wx.request工具，提供拦截器支持（计划开发中）

#### 安装

```shell script
npm install smart-wx-utils
```

#### 小程序工具库

1. 小程序API Promise化

    ```javascript
    const {wechat} = require('smart-wx-utils')
    
    // 目前2.1.0以下的API完全兼容，后期逐渐同步更新到最新版
    wechat.switchTab({url: '/pages/index'}).then(res => {
        console.log(res)
    })
    ```

2. 小程序API调用传参简化

    ```javascript
    const {wechat} = require('smart-wx-utils')
    
    // 和前面的代码等价，更多详情后面逐步更新，也可以看src中的源码
    wechat.switchTab('/pages/index').then(res => {
        console.log(res)
    })
    
    wechat.request('xxxxx', {a: 'b'}, {method: 'GET'}).then(res => {
        console.log(res.data)
    })
    ```

3. 小程序wx.request封装

    ```javascript
    const {utils} = require('smart-wx-utils')
    // 默认get
    utils.request.fetch(url, data, ops).then(res=> {
        console.log(res.data)
    })
    // get请求
    utils.request.get(url, data).then(res=> {
        console.log(res.data)
    })
    // post 请求
    utils.request.post(url, data).then(res=> {
        console.log(res.data)
    })
    ```

---
_Source: https://npm.io/package/smart-wx-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
