preface
In fact, all kinds of development are plug-ins, before I thought there was no small program, did not expect to have a later, yesterday started to try to integrate two plug-ins, did not expect twists and turns, here is a record of the pit I stepped on
To have appID small procedures to access the plug-in oh, experience of the not
The integration process
1. In the background of wechat public platform, log in, set – third-party service – add plug-in. Here’s an example of adding a “pole calendar”
Note that you can only add a maximum of 5
2. Search for the plugin you want and add it
Once you have added your plug-in, you can see it under Plug-in Management
3. Add a plugin to app.json
The plug-in name here is optional
This section uses TX-Map as an example. Refer to its documentation
Add relevant information to app.json
Provider is the AppID and Version is the version number
How to use it in a project is to look at the development documentation, and I found that some plug-ins have it, and some don’t, anyway, check it out for yourself
4. Reference the plugin in a JSON file on the target page
Note that tx-map is the name given in app.json, and map-route can also be named by itself, which is the name of the component used in WXML
5. Use the plug-in in the WXML file of the target page
To use the plugin’s JS interface, use requirePlugin(the name of the plugin named in app.json) in js to get the plugin object, such as:
let plugin = requirePlugin("tx-map")
Copy the code
6, check the effect
Some of the problems
- The plug-in is not authorized for use
- Cannot read property ‘version’ of undefined TypeError:Cannot read property ‘version’ of undefined
- Make a mistake!
The plug-in is not authorized for use
You can try adjusting your debug base library version, I was 1.9.1, just adjust to 2.1.1.
Cannot read property ‘version’ of undefined TypeError:Cannot read property ‘version’ of undefined
This really did not understand, because this error is based on the mood, for a while good for a while bad, a little unstable appearance, is said to reduce the debugging base library version
Make a mistake!
This also depends on the mood. (I am still confused, I do not know whether I am wrong or there is a problem with the plugin.)