Home > Article > Web Front-end > How to install vant in vue3 to implement on-demand import and global import
When using Vant in an existing project, you can install it through npm:
Vue 3 project, install the latest version of Vant
npm i vant
Vue 2 project, Install Vant 2
npm i vant@latest-v2
Of course, you can also install it through yarn or pnpm:
Install through yarn
yarn add vant
Install through pnpm
pnpm add vant
Global introduction
import Vant from 'vant'; import 'vant/lib/index.css'; createApp.use(Vant);
On-demand introduction
// 1. 引入你需要的组件 import { Button } from 'vant'; // 2. 引入组件样式 import 'vant/lib/index.css'; createApp(App).use(Button);
The above is the detailed content of How to install vant in vue3 to implement on-demand import and global import. For more information, please follow other related articles on the PHP Chinese website!