JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q57807F
  • License MIT

强大的、优雅的小程序 Promise 库

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

✨强大、优雅的小程序异步库🚀 小程序promise

npm npm Financial Contributors on Open Collective

NPM

优势

  • 方便集成:一处引用,处处使用
  • 把微信小程序所有异步 API promise 化并挂在到wx.pro 对象下。
  • 支持 finally

使用

普通使用方法

wxPromise.min.js copy 到 utils 目录中,然后在 app.js 中引入: import './utils/wxPromise.min.js'

使用NPM

npm i wx-promise-pro

然后使用 nodejs(require('wx-promise-pro'))或者 ES6 Moudle(import 'wx-promise-pro') 的方式引入。

支持 async、await

在需要的页面引入 regeneratorRuntime: import regeneratorRuntime from '/utils/regenerator-runtime.js'

支持所有的微信小程序异步API

使用 wxPromise 开发者无需关心兼容与否,只要是 wx 支持的 api,wx.pro 全部支持。

示例代码:

// 演示 wxPromise 的能力
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.hideLoading()
})

Contributors

Code Contributors

This project exists thanks to all the people who contribute.

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]