Skip to content

Button 按钮

按钮类型

按钮支持 primarysuccessinfowarningdanger 五种类型,默认为 primary

html
<template>
  <AButton>主要按钮</AButton>
  <AButton type="success">成功按钮</AButton>
  <AButton type="info">信息按钮</AButton>
  <AButton type="warning">警告按钮</AButton>
  <AButton type="danger">危险按钮</AButton>
</template>
<template>
  <AButton>主要按钮</AButton>
  <AButton type="success">成功按钮</AButton>
  <AButton type="info">信息按钮</AButton>
  <AButton type="warning">警告按钮</AButton>
  <AButton type="danger">危险按钮</AButton>
</template>

按钮大小

按钮支持 minismallnormallarge 四种大小,默认为 normal

html
<template>
  <AButton type="primary" size="mini">迷你按钮</AButton>
  <AButton type="success" size="small">小型按钮</AButton>
  <AButton type="info" size="normal">普通按钮</AButton>
  <AButton type="warning" size="large">大型按钮</AButton>
</template>
<template>
  <AButton type="primary" size="mini">迷你按钮</AButton>
  <AButton type="success" size="small">小型按钮</AButton>
  <AButton type="info" size="normal">普通按钮</AButton>
  <AButton type="warning" size="large">大型按钮</AButton>
</template>

按钮变体

按钮支持 solidoutlineghostlighttext 五种变体,默认为 solid

html
<template>
  <AButton variant="solid">实心按钮</AButton>
  <AButton type="success" variant="outline">空心按钮</AButton>
  <AButton type="info" variant="ghost">虚线按钮</AButton>
  <AButton type="warning" variant="light">次要按钮</AButton>
  <AButton type="danger" variant="text">文字按钮</AButton>
</template>
<template>
  <AButton variant="solid">实心按钮</AButton>
  <AButton type="success" variant="outline">空心按钮</AButton>
  <AButton type="info" variant="ghost">虚线按钮</AButton>
  <AButton type="warning" variant="light">次要按钮</AButton>
  <AButton type="danger" variant="text">文字按钮</AButton>
</template>

按钮状态

html
<template>
  <AButton loading>加载中</AButton>
  <AButton type="success" disabled>禁用状态</AButton>
</template>
<template>
  <AButton loading>加载中</AButton>
  <AButton type="success" disabled>禁用状态</AButton>
</template>

自定义

html
<template>
  <AButton icon="i-tabler-carrot" />
  <AButton type="success" custom-class="rounded-none aspect-square">

  </AButton>
  <AButton type="info" custom-class="rounded-full aspect-square">

  </AButton>
  <AButton type="warning">
    <template #icon>
      <i class="i-tabler-send" /> 插槽
    </template>
  </AButton>
  <AButton custom-class="bg-teal border-teal" open-type="getUserInfo" @click="getInfo">
    OpenType
  </AButton>
  <AButton :custom-class="['bg-gradient-to-r', 'from-indigo-500', 'to-pink-500']">
    背景渐变
  </AButton>
  <AButton type="danger" block>块级元素</AButton>
</template>
<template>
  <AButton icon="i-tabler-carrot" />
  <AButton type="success" custom-class="rounded-none aspect-square">

  </AButton>
  <AButton type="info" custom-class="rounded-full aspect-square">

  </AButton>
  <AButton type="warning">
    <template #icon>
      <i class="i-tabler-send" /> 插槽
    </template>
  </AButton>
  <AButton custom-class="bg-teal border-teal" open-type="getUserInfo" @click="getInfo">
    OpenType
  </AButton>
  <AButton :custom-class="['bg-gradient-to-r', 'from-indigo-500', 'to-pink-500']">
    背景渐变
  </AButton>
  <AButton type="danger" block>块级元素</AButton>
</template>

API

Props

参数说明类型默认值
type按钮类型,可选值为 primary success info warning dangerstringprimary
size按钮大小,可选值为 mini small normal' largestringnormal
variant按钮变体,可选值为 solid outline ghost light textstringsolid
icon自定义图标类名string-
disabled是否禁用按钮booleanfalse
loading是否显示为加载状态booleanfalse
block是否为块级元素booleanfalse
openType开放能力,具体请看 uni-app 稳定关于 button 组件部分说明string-

Events

事件名说明回调参数
click点击按钮时触发event: MouseEvent

Slots

名称说明
default按钮内容
icon自定义图标类名

MIT Licensed