Vant 适用于各种移动端 web 应用开发,特别是需要响应式设计和触摸优化的场景。它的组件和功能使其非常适合用于创建电商平台、社交媒体应用、内容展示平台等。
可以使用 npm、yarn、pnpm 或 bun 来安装 Vant:
# 安装适用于 Vue 3 项目的最新版 Vant
npm i vant
# 安装适用于 Vue 2 项目的 Vant 2
npm i vant@latest-v2
# 使用 yarn 安装
yarn add vant
# 使用 pnpm 安装
pnpm add vant
# 使用 bun 安装
bun add vant
快速开始:
import { createApp } from 'vue';
// 1. 引入你需要的组件
import { Button } from 'vant';
// 2. 引入组件样式
import 'vant/lib/index.css';
const app = createApp();
// 3. 注册你需要的组件
app.use(Button);
type: 按钮类型(default, primary, success, warning, danger)size: 按钮尺寸(large, normal, small, mini)icon: 按钮图标loading: 是否显示加载状态disabled: 是否禁用按钮click: 点击事件touchstart: 触摸开始事件show: 是否显示对话框title: 对话框标题message: 对话框消息内容showCancelButton: 是否显示取消按钮confirmButtonText: 确认按钮文本cancelButtonText: 取消按钮文本alert: 显示警告对话框confirm: 显示确认对话框close: 关闭对话框