Skip to content

引入组件

局部引入

ts
// parent.vue
const FButton = defineAsyncComponent(() => import('@/components/formaui/f-button/f-button.vue'))

基础用法

type属性:按钮类型(默认primary

例:primarysuccessdangerwarning

html
<f-button>按钮</f-button>
<f-button margin="16rpx 0 0" type="success">按钮</f-button>
<f-button margin="16rpx 0 0" type="warning">按钮</f-button>
<f-button margin="16rpx 0 0" type="danger">按钮</f-button>

shape属性:按钮形状(默认square

例:square(默认方形)circle(圆角)rightAngle(平角)

html
<f-button>按钮</f-button>
<f-button margin="16rpx 0 0" type="warning" shape="round">按钮</f-button>
<f-button margin="16rpx 0 0" type="danger" shape="rightAngle">按钮</f-button>

plain属性:空心按钮

html
<f-button margin="16rpx 0 0" plain>按钮</f-button>
<f-button margin="16rpx 0 0" type="warning" plain>按钮</f-button>
<f-button margin="16rpx 0 0" type="danger" plain>按钮</f-button>
<f-button margin="16rpx 0 0" plain text-color="#000" border-color="#f0f">按钮</f-button>

disabled属性:禁用状态

html
<f-button disabled>按钮</f-button>
<f-button margin="16rpx 0 0" type="warning" disabled>按钮</f-button>
<f-button margin="16rpx 0 0" type="danger" disabled>按钮</f-button>

loading属性:加载状态

html
<f-button loading>按钮</f-button>
<f-button margin="16rpx 0 0" type="warning" disabled loading>按钮</f-button>
<f-button margin="16rpx 0 0" type="danger" disabled loading>按钮</f-button>

width属性:按钮宽度(默认100%height属性:按钮高度(默认80rpx

html
<f-button width="372rpx" height="84rpx">按钮</f-button>
<f-button margin="16rpx 0 0" type="warning" width="280rpx" height="90rpx">按钮</f-button>
<f-button margin="16rpx 0 0" type="danger" width="200rpx" height="80rpx">按钮</f-button>

bg-color属性:按钮背景色

html
<f-button bg-color="#FC8F98">按钮</f-button>
<f-button margin="16rpx 0 0" bg-color="linear-gradient(117deg, #d78ffc 0%, #7316a3 100%)">按钮</f-button>
<f-button margin="16rpx 0 0" text-color="#000" bg-color="linear-gradient(117deg, #7bc7d3 0%, #1498ad 100%)">按钮</f-button>

插槽

名称说明
default显示内容

属性

名称类型说明默认值
typestring样式类型,可传入[primarysuccesswarningdanger]primary
shapestring按钮形状,可传入[squareroundrightAngle]square
plainboolean是否为空心按钮false
widthstring按钮宽度100%
heightstring按钮高度80rpx
marginstring按钮外边距0rpx
paddingstring按钮内边距0rpx
loadingboolean按钮加载状态false
bgColorstring按钮背景色-
borderColorstring按钮边框颜色-
borderRadiusstring按钮边框圆角12rpx
dashedboolean按钮边框虚线false
textColorstring按钮文字颜色#FFFFFF
fontSizestring按钮文字大小28rpx
formTypestring参考formType-
openTypestring参考openType-
appParameterstring打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效-
preventClickDurationnumber防止重复点击时间间隔,单位毫秒,默认 200 毫秒200

事件

事件名说明回调参数
click点击事件,设置 formType 时无需使用-
getuserinfo参考官方用户信息
getphonenumber参考官方手机号信息
chooseavatar参考官方头像信息
launchapp参考官方小程序打开 App 成功的回调
contact参考官方客服消息回调信息