Button 按钮

使用指南

  1. import { Button } from 'vant';
  2. Vue.use(Button);

代码演示

按钮类型

支持defaultprimaryinfowarningdanger五种类型,默认为default

  1. <van-button type="default">默认按钮</van-button>
  2. <van-button type="primary">主要按钮</van-button>
  3. <van-button type="info">信息按钮</van-button>
  4. <van-button type="warning">警告按钮</van-button>
  5. <van-button type="danger">危险按钮</van-button>

朴素按钮

  1. <van-button plain type="primary">朴素按钮</van-button>
  2. <van-button plain type="danger">朴素按钮</van-button>

禁用状态

通过disabled属性来禁用按钮,此时按钮不可点击

  1. <van-button disabled type="primary">禁用状态</van-button>
  2. <van-button disabled type="danger">禁用状态</van-button>

加载状态

  1. <van-button loading type="primary" />
  2. <van-button loading type="danger" loading-text="加载中..." />

按钮形状

  1. <van-button square type="primary">方形按钮</van-button>
  2. <van-button round type="danger">圆形按钮</van-button>

按钮尺寸

支持largenormalsmallmini四种尺寸,默认为normal

  1. <van-button size="large">大号按钮</van-button>
  2. <van-button size="normal">普通按钮</van-button>
  3. <van-button size="small">小型按钮</van-button>
  4. <van-button size="mini">迷你按钮</van-button>

API

参数说明类型默认值版本
type类型,可选值为 primary info warning dangerStringdefault1.6.6
size尺寸,可选值为 large small miniStringnormal-
text文字String--
tagHTML 标签Stringbutton-
native-type原生 type 属性String--
block是否为块级元素Booleanfalse-
plain是否为朴素按钮Booleanfalse1.1.13
square是否为方形按钮Booleanfalse1.2.0
round是否为圆形按钮Booleanfalse1.3.4
disabled是否禁用按钮Booleanfalse-
loading是否显示为加载状态Booleanfalse-
loading-text加载状态提示文字String-1.6.3
loading-size加载图标大小String20px1.6.7
url跳转链接String-1.6.5
to路由跳转对象,同 vue-router 的 toString | Object-1.6.5
replace跳转时是否替换当前页面历史Stringfalse1.6.5

Event

事件名说明参数
click点击按钮且按钮状态不为加载或禁用时触发-

原文: https://youzan.github.io/vant/#/zh-CN/button