The installation
Step 1: Install via NPM
If you haven't already initialized the project, be sure to initialize it first. 1.npm init 2.npm install # 3. Install NPM i@vant/appellate P-s --production install NPM i@vant/appellate P-s --production install NPM I@vant/appellate P-s --production install NPM I@vant/appellate P-s --production install NPM I@vant/appellate P-s --production -S --productionCopy the code
Step 2: Build the NPM package
Open wechat developer tools, click Tools -> Build NPM, and check the use NPM module option. After the build is complete, you can introduce components
Step 3: Use
- The introduction of the component
Using the Button component as an example, you only need to configure the path for the Button in app.json or index.json
If you are using @vant/ retry by downloading the source code, change the path to the same directory that @vant/ retry is in.
// app.json
"usingComponents": {
"van-button": "/miniprogram_npm/@vant/weapp/button/index"
}
Copy the code
- Using the component
Once components are introduced, they can be used directly in WXML
<van-button type="primary"> </van-button>Copy the code