Package Exports
- wx-promise-pro
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wx-promise-pro) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
wx-promise-pro
✨强大、优雅的微信小程序异步库🚀
优势
- 方便集成:一处引用,处处使用
- 把微信小程序所有异步 API promise 化并挂在到
wx.pro对象下 - 支持 ES2018
finally特性 - 支持 TypeScript 开发
安装
你也可以直接把
dist目录下的wx-promise-pro.js拷贝到项目里使用
$ npm i wx-promise-pro -S
# or
$ yarn add wx-promise-pro初始化
import { promisifyAll, promisify } from 'wx-promise-pro'
// promisify all wx‘s api
promisifyAll()
// promisify single api
promisify(wx.getSystemInfo)().then(console.log)示例代码
wx.pro.showLoading({
title: '加载中',
mask: true
})
wx.pro.request({
url: 'https://cnodejs.org/api/v1/topics',
data: {},
method: 'GET',
header: {'content-type': 'application/json'}
}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
}).finally(() => {
wx.pro.hideLoading()
})