让微信小城的对全局对wx
的api返回promise.
对所有api增加Async后缀,则调用异步api,并且返回promise.
npm install wxapp-promisify
// es6
import wx from '@axetroy/wxapp-promisify';
// commandJS
var wx = require('@axetroy/wxapp-promisify');
wx
.getUserInfoAsync()
.then(function(userInfo) {
console.log(userInfo);
})
.catch(function(err) {
console.error(err);
});
wx
.showToastAsync({ title: 'This is title' })
.then(function(res) {})
.catch(function(err) {});
git clone https://github.com/axetroy/wxapp-promisify.git
cd ./wxapp-promisify
yarn
You can flow Contribute Guide
Axetroy 💻 🔌 |
---|
The MIT License