May 17, 2021 WeChat Mini Program Development Document
The gadget supports the installation of third-party packages using npm starting with the underlying library version 2.2.1, and therefore also supports the development and use of third-party custom component packages. For more information about the npm feature, you can first read the relevant documentation (npm support).
To develop an open source custom component package for others to use, you first need to be clear about how others want to use the package, and you can skip this document if you are simply copying the small program directory for direct use. Subsequent content in this document is described under the premise of npm managing custom component packages.
Before development, developers are required to have basic knowledge .js node.js and npm, as well as the need to have developer tools ready to support npm functionality, so download this.
In order to make it easier for developers to quickly build a custom component package project that can be used for development, debugging, and testing, the official provides a project template that can be downloaded in three ways:
The build in the project template is based on gulp and webpack and supports commands such as development, build, testing, and more, as detailed in the README.md template.
Official offering Command line tool Used to quickly initialize a project.Perform the following command to install the command line tool:
npm install -g @wechat-miniprogram/miniprogram-cli
Then create an empty directory as a project root directory, execute in this root directory:
miniprogram init --type custom-component
After the command is executed, you will find a lot of files in the root directory, which is based on the complete project generated by the official project template, and then developers can develop and modify them here.
More usage of command line tools can view GitHub warehouses README.md document.
PS: The first time I use the MiniProgram init initialization project to pull the template on Github, so you need to ensure that the network is open.
For custom components, you can see the documentation unit test 。
The following custom components are officially available for reference and use:
The following official custom component extensions can be referenced and used: