Skip to content

Button

常用的操作按钮

基础用法

使用 typeplainroundcircle 来定义按钮的样式。







<template>
  <ez-button> hello </ez-button>
  <ez-button type="primary"> Primary </ez-button>
  <ez-button type="success"> Success </ez-button>
  <ez-button type="info"> Info </ez-button>
  <ez-button type="warning"> Warning </ez-button>
  <ez-button type="danger"> Danger </ez-button><br /><br />
  <ez-button plain> hello </ez-button>
  <ez-button type="primary" plain> Primary </ez-button>
  <ez-button type="success" plain> Success </ez-button>
  <ez-button type="info" plain> Info </ez-button>
  <ez-button type="warning" plain> Warning </ez-button>
  <ez-button type="danger" plain> Danger </ez-button><br /><br />

  <ez-button round> hello </ez-button>
  <ez-button type="primary" round> Primary </ez-button>
  <ez-button type="success" round> Success </ez-button>
  <ez-button type="info" round> Info </ez-button>
  <ez-button type="warning" round> Warning </ez-button>
  <ez-button type="danger" round> Danger </ez-button><br /><br />

  <ez-button circle> <ez-icon icon="star" /> </ez-button>
  <ez-button type="primary" circle> <ez-icon icon="star" /> </ez-button>
  <ez-button type="success" circle> <ez-icon icon="star" /> </ez-button>
  <ez-button type="info" circle> <ez-icon icon="star" /> </ez-button>
  <ez-button type="warning" circle> <ez-icon icon="star" /> </ez-button>
  <ez-button type="danger" circle> <ez-icon icon="star" /> </ez-button>
</template>

禁用状态

你可以使用 disabled 属性来定义按钮是否被禁用, 该属性接受一个 Boolean 类型的值。

<template>
  <div>
    <ez-button disabled>Default</ez-button>
    <ez-button type="primary" disabled>Primary</ez-button>
    <ez-button type="success" disabled>Success</ez-button>
    <ez-button type="info" disabled>Info</ez-button>
    <ez-button type="warning" disabled>Warning</ez-button>
    <ez-button type="danger" disabled>Danger</ez-button>
  </div>
</template>

链接按钮

你可以使用 link 属性来定义按钮是否为link状态, 该属性接受一个 Boolean 类型的值。



<template>
  <div>
    <ez-button link>Default</ez-button>
    <ez-button type="primary" link>Primary</ez-button>
    <ez-button type="success" link>Success</ez-button>
    <ez-button type="info" link>Info</ez-button>
    <ez-button type="warning" link>Warning</ez-button>
    <ez-button type="danger" link>Danger</ez-button><br /><br />
    <ez-button link disabled>Default</ez-button>
    <ez-button type="primary" link disabled>Primary</ez-button>
    <ez-button type="success" link disabled>Success</ez-button>
    <ez-button type="info" link disabled>Info</ez-button>
    <ez-button type="warning" link disabled>Warning</ez-button>
    <ez-button type="danger" link disabled>Danger</ez-button>
  </div>
</template>

图标按钮

使用 icon 属性来为按钮添加图标。图标名称请看 fontawesome 官网 https://fontawesome.com/icons。

<template>
  <div class="icon block">
    <ez-button icon="star"> Star ez-button </ez-button>
  </div>
</template>

加载状态按钮

通过设置 loading 属性为 true 来显示正在加载的状态。

<template>
  <div class="loading block">
    <ez-button loading> Loading... </ez-button>
  </div>
</template>

调整尺寸

除了默认的大小,按钮组件还提供了几种额外的尺寸可供选择,以便适配不同的场景。

使用 size 属性额外配置尺寸,可使用 largesmall两种值。



<template>
  <div class="size block">
    <ez-button size="large"> Large </ez-button>
    <ez-button> Default </ez-button>
    <ez-button size="small"> Small </ez-button>
    <ez-button size="large" icon="search"> Large </ez-button>
    <ez-button icon="search"> Default </ez-button>
    <ez-button size="small" icon="search"> Small </ez-button><br /><br />
    <ez-button size="large" round> Large </ez-button>
    <ez-button round> Default </ez-button>
    <ez-button size="small" round> Small </ez-button>
    <ez-button size="large" round icon="search"> Large </ez-button>
    <ez-button round icon="search"> Default </ez-button>
    <ez-button size="small" round icon="search"> Small </ez-button>
  </div>
</template>

Button API

Button Attributes

NameDescriptionTypeDefault
size尺寸enum - 'large'| 'small'
type类型enum - 'primary'| 'success'| 'warning'| 'danger'| 'info'
plain是否为朴素按钮booleanfalse
round是否为圆角按钮booleanfalse
circle是否为圆形按钮booleanfalse
loading是否为加载中状态booleanfalse
disabled按钮是否为禁用状态booleanfalse
icon图标组件string
autofocus原生 autofocus 属性booleanfalse
native-type原生 type 属性enum - 'button'| 'submit'| 'reset'button

Button Slots

插槽名说明
default自定义默认内容