vue2
- vant
Use of component library
Official website: http://vant-contrib.gitee.io/vant/v2/#/zh-CN/home
The first step, install the vant
2.x
version
In the official website, click "Quick Start" on the left , there is a detailed installation introduction, for
npm
example, as shown below:
npm
vant
2.x
The corresponding code for the installed version:npm i vant@latest-v2 -S
The second step, import components
On the official website, click "Quick Start" on the left , scroll down, and find "Introduce Components" . There are detailed introduction methods, as shown in the figure below: [There are three methods, the first one is recommended, follow the steps in the documentation Can】
Example: (Method 1. Automatically import components on demand (recommended))
- The first step, install the plugin:
npm i babel-plugin-import -D
- The second step,
babel.config.js
add the configuration in:
The third step, Vant
the method of using the component [important】
On the official website, click "Advanced Usage" on the left , scroll down, find "Partial Registration" , there is a detailed introduction to the usage, as shown below:
Example: Use
vant
the tab page in the component library, as shown below:
The result is as follows: