【笔记】Vant学习笔记

前言

轻量、可定制的移动端 Vue 组件库(官网

下载依赖

Vue3

1
npm install vant

Vue2

1
npm install vant@latest-v2

引入并注册组件

全量引入

src/main.js
1
2
3
4
5
6
7
8
import { createApp } from "vue"
import App from "./App.vue"
import Vant from "vant"
import "vant/lib/index.css"

const app = createApp(App);
app.use(Vant);
app.mount("#app");

按需引入

使用组件

按钮

src/views/Home.vue
1
2
3
<template>
<van-button type="primary">主要按钮</van-button>
</template>

完成