Home > Web Front-end > Vue.js > How to install vant in vue3 to implement on-demand import and global import

How to install vant in vue3 to implement on-demand import and global import

王林
Release: 2023-05-19 18:40:06
forward
2515 people have browsed it

Installation

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
Copy after login

Vue 2 project, Install Vant 2

npm i vant@latest-v2
Copy after login

Of course, you can also install it through yarn or pnpm:

Install through yarn

yarn add vant
Copy after login

Install through pnpm

pnpm add vant
Copy after login

Introduction

Global introduction

import Vant from 'vant';
import 'vant/lib/index.css';
createApp.use(Vant);
Copy after login

On-demand introduction

// 1. 引入你需要的组件
import { Button } from 'vant';
// 2. 引入组件样式
import 'vant/lib/index.css';

createApp(App).use(Button);
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template