1.0.2 • Published 3 years ago

miniapp-wx-tools v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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 on wx.navigateTo() api
  • login(): Package based on wx.login()api.
  • request: Based on the encapsulation of wx.request()api, it is more flexible than the native way and supports the most basic http connection configuration.
  • loading: Based on the objects encapsulated by wx.showLoaidng() and wx.hideLoading.
  • toast: Based on the objects encapsulated by wx.showToat() and wx.hideToast().
  • getUserProfile(): Based on the object encapsulated by wx.getUserProfile().
  • localstorage: Encapsulation based on WeChat data cache.

The above APIs all support promises.