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 版的差異

小程序按鈕沒有 nativeType / href / target 語義,所以這三個 props 在本庫不實作。其餘 API 相同。