WeChat mini-program currently only support development using
WeChat Mini Program plugins are divided into pages, components and interfaces. Developers can use the
taro init command and then select Generate WeChat Mini Program Plugin Template to generate a Taro WeChat Mini Program plugin project containing the above three plugin types in the current directory.
After creating the template, you first need to modify the appid field in
project.config.json and the prodiver field in
src/app.js to the same appid.
The recommended plugin project structure is as follows:
Note that the last thing published is the contents of the plugin folder. All the contents of the plugin and its dependencies except for the npm package should be written in the plugin folder. The pages in
src/pages are just for debugging the plugin.
Add the Taro plugin project root in WeChat Developer Tools.
Add the pages field of plugin.json to the page plugin path.
The page uses the path: plugin://[name of registered plugin in app.js]/[name of registered page in plugin.json] for jumping.
The publicComponents field of plugin.json adds the component plugin path.
Configure the plugin name and plugin path in the page configuration config.usingComponents (plugin://[name of plugin registered in app.js]/[name of component registered in plugin.json]).
If you need to pass parameters to the plugin, you need to pass them uniformly in the component's
The main field of plugin.json adds the path to the interface plugin.
Use in the page: