Skip to content

Button 按钮 ​

基础按钮组件。渲染载体是 uni 内置 <button>(编译为各端原生按钮),点击事件由 uni 编译为 bindtap。

基础用法 ​

vue
<template>
  <lh-button>默认</lh-button>
  <lh-button type="primary">主要</lh-button>
  <lh-button type="success">成功</lh-button>
  <lh-button type="warning">警告</lh-button>
  <lh-button type="danger">危险</lh-button>
  <lh-button type="info">信息</lh-button>
</template>

状态与形状 ​

vue
<template>
  <lh-button loading>加载中</lh-button>
  <lh-button disabled>禁用</lh-button>
  <lh-button plain>朴素</lh-button>
  <lh-button round>圆角</lh-button>
  <lh-button circle icon="search" />
  <lh-button block>块级(占满一行)</lh-button>
  <lh-button icon="search" type="primary">带图标</lh-button>
</template>

Props ​

属性说明类型默认值
type类型'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info''default'
size尺寸;不传则从 ConfigProvider 继承'small' | 'medium' | 'large'—
loading加载中状态booleanfalse
disabled禁用booleanfalse
plain朴素(描边)样式booleanfalse
block块级布局booleanfalse
round圆角booleanfalse
circle圆形booleanfalse
icon图标名称LhIconName—
customClass自定义类名(透传到根节点)string—
themeVars组件级主题变量Record<string, string>—
bgPattern组件级背景花纹string—
sx快速布局属性LhSxProps—

Events ​

事件说明回调参数
click点击(event)

与 Vue3 版的差异

小程序 button 无 nativeType / href / target 语义,这三个属性在本库不实现。 其余 API 一致。