当前位置: 首页 > 文档资料 > FeArt 中文文档 >

Button 按钮

优质
小牛编辑
119浏览
2023-12-01

使用指南

引入方式

import { button } from 'feart';

components: {
  'fe-button': Button,
},

代码演示

按钮类型

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

<fe-button>默认按钮</fe-button>
<fe-button type="primary">主要按钮</fe-button>
<fe-button type="warn">警告按钮</fe-button>
<fe-button type="danger">危险按钮</fe-button>

朴素按钮

通过 plain 属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为透明。

<fe-button plain>朴素按钮</fe-button>
<fe-button plain type="primary">朴素按钮</fe-button>

禁用状态

通过 disabled 属性来禁用按钮,禁用状态下按钮不可点击

<fe-button disabled>默认按钮</fe-button>
<fe-button plain disabled>朴素按钮</fe-button>
<fe-button type="primary" disabled>主要按钮</fe-button>

加载状态

通过 loading 属性设置按钮为加载状态

<fe-button loading></fe-button>
<fe-button plain loading></fe-button>
<fe-button type="primary" loading>加载中</fe-button>
<fe-button plain type="primary" loading>加载中</fe-button>

按钮形状

通过 square 设置方形按钮,通过 round 设置圆形按钮

<fe-button plain type="primary" square>方角 plain</fe-button>
<fe-button type="primary" round>圆角 plain</fe-button>

图标按钮

通过 icon 属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL

<fe-button icon="star">按钮</fe-button>
<fe-button icon="https://nuofe.nntest.cn/feart/images/demoimgs/nuoyan-logo.jpg">
  按钮
</fe-button>

按钮尺寸

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

<fe-button size="large" type="primary">按钮</fe-button>
<fe-button size="normal" type="primary">按钮</fe-button>
<fe-button size="small" type="primary">按钮</fe-button>
<fe-button size="mini" type="primary">按钮</fe-button>

自定义颜色

<fe-button color="red">单色按钮</fe-button>
<fe-button color="red" plain>单色按钮</fe-button>
<fe-button color="linear-gradient(90deg, #1D62F0, #19D5FD)">多彩渐变</fe-button>

跳转链接

<fe-button link="/">去主页</fe-button>
<fe-button link="https://www.jss.com.cn/">去主页</fe-button>

块级按钮

<fe-button type="primary" block>块级按钮</fe-button>

和 flexbox 同用

<fe-flexbox :gutter="0">
  <fe-flexbox-item :span="2" style="text-align: center;">
    <img src="https://m.axnsc.com/Contents/images/Shopping-2.png" alt="" style="width:20px" />
    <p style="font-size: 10px;margin-top: -5px;color: #808185;">购物车</p>
  </fe-flexbox-item>
  <fe-flexbox-item>
    <fe-button type="primary" color="#FE8604" block square>加入购物车</fe-button>
  </fe-flexbox-item>
  <fe-flexbox-item>
    <fe-button type="primary" color="#FF3C25" square block>立即购买</fe-button>
  </fe-flexbox-item>
</fe-flexbox>

API

参数说明类型默认值可选值
type按钮显示类型stringdefaultprimary warning danger
size按钮尺寸stringnormallarge small mini
text按钮文字(也可通过默认 slot 的方式传入)string--
icon左侧图标名称或图片链接string-Icon 组件
native-type原生 button 标签 type 属性Stringbuttonsubmit reset
no-border是否无边框booleanfalsetrue false
plain是否为朴素按钮booleanfalsetrue false
block是否为块级元素booleanfalsetrue false
square是否为方形按钮booleanfalsetrue false
round是否为圆形按钮booleanfalsetrue false
disabled是否禁用按钮booleanfalsetrue false
loading是否显示为加载状态booleanfalsetrue false
loading-text加载状态提示文字string--
loading-type加载图标类型Stringcircularspinner
loading-size加载图标大小String20px-
link跳转链接String--
className样式类名(和 scoped 冲突)String--
color按钮颜色,支持传入linear-gradient渐变色String--

Events

绑定点击事件请使用@click.native

参数说明回调参数
click点击按钮,且按钮状态不为加载或禁用时触发event: Event