miniapp-wx-tools
v1.0.2
Published
Encapsulation based on WeChat applet api
Downloads
5
Readme
miniapp-wx-tools
miniapp-wx-tools is a secondary package based on the api provided by the WeChat applet. It is more convenient, concise and flexible to use.
Only applicable to: WeChat Mini Program, other environments are not supported.
Install
npm install --save miniapp-wx-tools
use
Due to the limitation of WeChat Mini Programs, when using npm packages, a process of building npm packages must be carried out. For this process, please refer to WeChat Developer Tools: Tools -> Build npm.
In order to avoid other errors, it is recommended to enable the use of npm module under the local settings of WeChat developer tools, refer to: detailed -> local settings -> use npm module.
// app.js
const wxt = require("miniapp-wx-tools");
App({
globalData: {
wxt,
},
});
API
navigateTo(url,param)
: package based onwx.navigateTo()
apilogin()
: Package based onwx.login()
api.request
: Based on the encapsulation ofwx.request()
api, it is more flexible than the native way and supports the most basic http connection configuration.loading
: Based on the objects encapsulated bywx.showLoaidng()
andwx.hideLoading
.toast
: Based on the objects encapsulated bywx.showToat()
andwx.hideToast()
.getUserProfile()
: Based on the object encapsulated bywx.getUserProfile()
.localstorage
: Encapsulation based on WeChat data cache.
The above APIs all support promises.