更新记录
1.2.0(2026-11-10)
下载此版本
- 新增
o-btn-group 按钮组组件:组内按钮默认无缝相邻(无间距),需要时用 gutter 增加间距(rpx),首尾按钮与边缘自动对齐
- 组级参数级联:size / round / disabled 通过 provide/inject 下发到组内按钮,block 模式下组内按钮自动均分宽度
- 拼接按钮组:group 加
joined 后按钮无缝相连,外侧圆角由容器统一裁切(规避小程序无法穿透子组件样式的问题),实心按钮间以半透明分隔线过渡,可与 size / round / plain / disabled 混用
- o-btn 配合调整:size 支持留空跟随组级联(默认表现不变);新增组内均分样式
o-btn--group-block 与拼接样式 o-btn--joined / o-btn--join-divider
1.1.3(2026-11-04)
下载此版本
- 默认圆角由 8rpx 调整为 16rpx,视觉更柔和
- 各尺寸圆角按高度等比缩放:xs 10rpx / sm 12rpx / md(默认)16rpx / lg 18rpx,避免小按钮被圆角「吃掉」、大按钮显得过方
- 默认边框色由
#eaedec 调整为 #ddd,白色 / 镂空按钮边界更清晰
- 演示页重写,覆盖 type、size、plain、square/round、icon、block、disabled、loading、open-type、form-type 全部参数
1.1.1(2026-11-02)
下载此版本
- 修复:
block / round / square / plain / disabled / loading 以无值属性写法(如 <o-btn block>)传入时被当作 false,块级、圆角等样式不生效;布尔判定统一为 true / '' / 'true' / '1' 为真,显式 'false' 仍为假
查看更多
平台兼容性
uni-app(3.8.10)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
| √ |
√ |
√ |
√ |
√ |
- |
√ |
√ |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| √ |
√ |
√ |
√ |
√ |
√ |
- |
√ |
√ |
√ |
- |
- |
uni-app x(3.8.10)
| Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
- |
- |
- |
- |
o-btn
组件初衷是做多几个type不用额外定义样式就能满足需求 提高效率
基本用法
完整演示页见项目 pages/button/index.vue,覆盖全部参数。核心用法:
<template>
<view class="p-2">
<!-- 颜色与点击事件 -->
<o-btn type="primary" @click="onClick">主要按钮</o-btn>
<o-btn type="success" @click="onClick">成功按钮</o-btn>
<o-btn type="warning" @click="onClick">警告按钮</o-btn>
<o-btn type="error" @click="onClick">危险按钮</o-btn>
<o-btn @click="onClick">默认按钮</o-btn>
<!-- 尺寸:xs / sm / md(默认)/ lg -->
<o-btn size="xs" type="primary">迷你按钮</o-btn>
<o-btn size="sm" type="primary">小按钮</o-btn>
<o-btn size="lg" type="primary">大按钮</o-btn>
<!-- 形状:square 方形 / round 胶囊 -->
<o-btn type="blue" square>方形按钮</o-btn>
<o-btn type="blue" round>胶囊按钮</o-btn>
<!-- 镂空:白底,保留主题色文字与边框 -->
<o-btn type="primary" plain>主要镂空</o-btn>
<o-btn type="purple" plain round>紫色镂空胶囊</o-btn>
<!-- 图标:o-icon 内置图标名走字体图标;含 . 的地址走图片图标 -->
<o-btn type="primary" icon="star-filled">字体图标</o-btn>
<o-btn type="blue" icon="/static/2.png">图片图标</o-btn>
<!-- 块级 -->
<o-btn block type="primary">块级主要按钮</o-btn>
<!-- 禁用 -->
<o-btn type="primary" disabled>主要禁用</o-btn>
<!-- 加载态:loading 后隐藏图标,loading-text 自定义提示 -->
<o-btn type="primary" :loading="submitting" :loading-text="submitting ? '提交中…' : ''" @click="mockSubmit">
{{ submitting ? '请稍候' : '点击提交' }}
</o-btn>
<!-- 小程序开放能力(H5 自动忽略) -->
<o-btn type="green" open-type="share">转发分享</o-btn>
<!-- 表单提交(配合 form 组件) -->
<form @submit="onFormSubmit">
<input name="keyword" />
<o-btn type="primary" form-type="submit" size="sm">提交</o-btn>
<o-btn form-type="reset" size="sm">重置</o-btn>
</form>
</view>
</template>
oBtn Props
| 属性名 |
类型 |
默认值 |
可选值 |
备注 |
| type |
string |
default |
red、green、blue、danger、orange、yellow、brown、pink、purple、black、grey、gray、white、default、primary、success、info、warning、error、cyan |
按钮颜色类型(class 着色,不会误触发表单提交) |
| size |
string |
md |
xs、sm、md、lg |
尺寸,圆角随尺寸等比缩放(xs 10rpx / sm 12rpx / md 16rpx / lg 18rpx);留空时跟随 o-btn-group 的 size 级联 |
| icon |
string |
|
o-icon 内置图标名(如 home、cart、play-demo-filled,详见 o-icon 文档)或图片链接 |
自动识别:含 . 视为图片,否则走 o-icon 内置字体(⚠️ 1.1.2 起不再支持自定义 iconfont 类名,如 icon-xxx) |
| block |
boolean |
false |
true |
开启块级元素 |
| plain |
boolean |
false |
true |
镂空按钮 |
| square |
boolean |
false |
true |
方形按钮 |
| round |
boolean |
false |
true |
圆形按钮 |
| disabled |
boolean |
false |
true |
禁用按钮 |
| loading |
boolean |
false |
true |
加载状态 |
| loading-text |
string |
- |
|
加载状态提示文字 |
| open-type |
string |
- |
share、contact、getPhoneNumber… |
小程序开放能力(H5 自动忽略) |
| form-type |
string |
- |
submit、reset |
表单提交类型,配合 form 组件 |
oBtn Events
| 事件名称 |
说明 |
返回参数 |
| @click |
监听点击事件 |
- |
基本用法(按钮组)
<template>
<view>
<!-- 基础按钮组:间距由 gutter 控制,size / round / disabled 会级联到组内按钮 -->
<o-btn-group>
<o-btn type="primary" plain>左侧</o-btn>
<o-btn type="primary">中间</o-btn>
<o-btn type="primary" plain>右侧</o-btn>
</o-btn-group>
<!-- 尺寸与间距级联(组内默认无间距,gutter 单位 rpx) -->
<o-btn-group size="lg" gutter="24">
<o-btn type="success" icon="star-filled">收藏</o-btn>
<o-btn type="warning" icon="cart-filled">加购</o-btn>
</o-btn-group>
<!-- 胶囊筛选组 -->
<o-btn-group size="sm" round>
<o-btn type="purple" plain>天</o-btn>
<o-btn type="purple" plain>周</o-btn>
<o-btn type="purple">全部</o-btn>
</o-btn-group>
<!-- 块级按钮组:占满一行,组内按钮自动均分宽度 -->
<o-btn-group block>
<o-btn type="primary">取消</o-btn>
<o-btn type="success">确认</o-btn>
</o-btn-group>
<!-- 整组禁用 -->
<o-btn-group disabled>
<o-btn type="primary">已选 A</o-btn>
<o-btn type="primary">已选 B</o-btn>
</o-btn-group>
<!-- 拼接按钮组:按钮无缝相连,常用于分页、多项类操作 -->
<o-btn-group joined>
<o-btn type="primary" icon="arrow-left">上一页</o-btn>
<o-btn type="primary">下一页</o-btn>
</o-btn-group>
<!-- 纯图标操作组(icon 不传文字即为纯图标按钮) -->
<o-btn-group joined size="lg">
<o-btn type="primary" icon="edit"></o-btn>
<o-btn type="primary" icon="share"></o-btn>
<o-btn type="primary" icon="delete"></o-btn>
</o-btn-group>
</view>
</template>
oBtnGroup Props
| 属性名 |
类型 |
默认值 |
可选值 |
备注 |
| size |
string |
md |
xs、sm、md、lg |
尺寸级联:组内按钮未显式指定 size 时生效 |
| block |
boolean |
false |
true |
占满一行,组内按钮自动均分宽度 |
| gutter |
number / string |
0 |
|
相邻按钮间距(rpx),默认无缝相邻;首尾按钮与边缘自动对齐 |
| round |
boolean |
false |
true |
胶囊组:组内按钮统一全圆角外观 |
| disabled |
boolean |
false |
true |
整组禁用(级联到组内所有按钮) |
| joined |
boolean |
false |
true |
拼接组:按钮无缝相连,外侧圆角由容器统一裁切,实心按钮间以半透明分隔线过渡 |
级联规则:size / round / disabled 通过 provide/inject 下发;子按钮显式设置的属性中,size 优先于组级值,round / disabled 与组级值取「或」(即组禁用后无法在子按钮上单独解除)。