按钮 basic-button
2026年7月20日大约 7 分钟
按钮 basic-button
触发交互动作的按钮,支持四态样式(常态 / 悬停 / 点击 / 选中)。
- 类型串:
basic-button默认尺寸:[120, 40]分类:控件
实时预览
下面渲染的是真实组件(与编辑器 / 运行时同源)。修改右侧「样式参数」,左侧预览实时更新;点击底部「全页面查看」可放大。
属性
下表为本组件特有的属性;
position/size/opacity/background/border/ 联动选中 / 筛选等通用参数见组件手册总览。
basic
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
text | 文本 | string | 按钮 | |
text-arrangement | 文本排列 | select(radioGroup) | horizontal | 可选:horizontal / vertical |
padding | 内边距 | vector<上,右,下,左>(unit=px) | [8,16,8,16] | |
show-select | 启用选中态 | boolean | false | |
checked | 默认选中 | boolean | false |
stateStyles
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
text-default-font | 字体 | font(gradient=true,underline=true,line-through=true) | {"family":"","size":16,"color":"#ffffff","bold":false,"it… | |
font-default-spacing | 字体间隔 | number(unit=px) | 0 | |
text-default-position | 水平对齐方式 | select(radioGroup) | center | 可选:left / center / right |
text-default-vertical | 竖直对齐方式 | select(radioGroup) | center | 可选:top / center / bottom |
text-offset-default | 文字偏移 | vector<X,Y>(unit=px) | [0,0] | |
font-default-shadow-color | 外发光颜色 | color | #ffffff | |
font-default-shadow-blur | 外发光模糊程度 | number(unit=px) | -1 | |
font-default-shadow-offset | 发光偏移 | vector<X,Y>(unit=px) | [0,0] | |
border-default-color | 边框颜色 | color | #2f7bff | |
border-default-width | 边框宽度 | number(unit=px,min=0) | 0 | |
border-default-radius | 圆角半径 | number(unit=px,min=0) | 6 | |
border-default-style | 边框样式 | select(radioGroup) | solid | 可选:solid / dashed / dotted / none |
background-default-color | 背景颜色 | color(gradient) | #2f7bff | |
background-default-image | 背景图/视频 | file | — | |
background-default-fill-type | 填充方式 | select(radioGroup) | stretch | 可选:stretch / tile / none |
background-default-image-size | 图片比例 | number(unit=%) | 100 | |
background-default-image-position | 图片位置 | vector<X,Y>(unit=px) | [0,0] | |
background-default-blur | 背景模糊 | number(unit=px,min=0) | 0 | |
background-default-use-nine-patch | 是否使用点九 | boolean | false | |
background-default-nine-patch | 点九编辑 | nine-patch | {} | |
show-click | 启用点击态 | boolean | false | |
text-click-font | 字体 | font(gradient=true,underline=true,line-through=true) | 继承 | |
font-click-spacing | 字体间隔 | number(unit=px) | 继承 | |
text-click-position | 水平对齐方式 | select(radioGroup) | 继承 | 可选:left / center / right |
text-click-vertical | 竖直对齐方式 | select(radioGroup) | 继承 | 可选:top / center / bottom |
text-offset-click | 文字偏移 | vector<X,Y>(unit=px) | 继承 | |
font-click-shadow-color | 外发光颜色 | color | 继承 | |
font-click-shadow-blur | 外发光模糊程度 | number(unit=px) | 继承 | |
font-click-shadow-offset | 发光偏移 | vector<X,Y>(unit=px) | 继承 | |
border-click-color | 边框颜色 | color | 继承 | |
border-click-width | 边框宽度 | number(unit=px,min=0) | 继承 | |
border-click-radius | 圆角半径 | number(unit=px,min=0) | 继承 | |
border-click-style | 边框样式 | select(radioGroup) | 继承 | 可选:solid / dashed / dotted / none |
background-click-color | 背景颜色 | color(gradient) | 继承 | |
background-click-image | 背景图/视频 | file | 继承 | |
background-click-fill-type | 填充方式 | select(radioGroup) | 继承 | 可选:stretch / tile / none |
background-click-image-size | 图片比例 | number(unit=%) | 继承 | |
background-click-image-position | 图片位置 | vector<X,Y>(unit=px) | 继承 | |
background-click-blur | 背景模糊 | number(unit=px,min=0) | 继承 | |
background-click-use-nine-patch | 是否使用点九 | boolean | 继承 | |
background-click-nine-patch | 点九编辑 | nine-patch | 继承 | |
animation-click-show | 开启涟漪动画 | boolean | false | |
animation-click-time | 动画时长 | number<float>(step=0.05,unit=秒) | 0.35 | |
show-hover | 启用悬停态 | boolean | false | |
text-hover-font | 字体 | font(gradient=true,underline=true,line-through=true) | 继承 | |
font-hover-spacing | 字体间隔 | number(unit=px) | 继承 | |
text-hover-position | 水平对齐方式 | select(radioGroup) | 继承 | 可选:left / center / right |
text-hover-vertical | 竖直对齐方式 | select(radioGroup) | 继承 | 可选:top / center / bottom |
text-offset-hover | 文字偏移 | vector<X,Y>(unit=px) | 继承 | |
font-hover-shadow-color | 外发光颜色 | color | 继承 | |
font-hover-shadow-blur | 外发光模糊程度 | number(unit=px) | 继承 | |
font-hover-shadow-offset | 发光偏移 | vector<X,Y>(unit=px) | 继承 | |
border-hover-color | 边框颜色 | color | 继承 | |
border-hover-width | 边框宽度 | number(unit=px,min=0) | 继承 | |
border-hover-radius | 圆角半径 | number(unit=px,min=0) | 继承 | |
border-hover-style | 边框样式 | select(radioGroup) | 继承 | 可选:solid / dashed / dotted / none |
background-hover-color | 背景颜色 | color(gradient) | 继承 | |
background-hover-image | 背景图/视频 | file | 继承 | |
background-hover-fill-type | 填充方式 | select(radioGroup) | 继承 | 可选:stretch / tile / none |
background-hover-image-size | 图片比例 | number(unit=%) | 继承 | |
background-hover-image-position | 图片位置 | vector<X,Y>(unit=px) | 继承 | |
background-hover-blur | 背景模糊 | number(unit=px,min=0) | 继承 | |
background-hover-use-nine-patch | 是否使用点九 | boolean | 继承 | |
background-hover-nine-patch | 点九编辑 | nine-patch | 继承 | |
animation-hover-show | 开启涟漪动画 | boolean | false | |
animation-hover-time | 动画时长 | number<float>(step=0.05,unit=秒) | 0.35 | |
text-select-font | 字体 | font(gradient=true,underline=true,line-through=true) | 继承 | |
font-select-spacing | 字体间隔 | number(unit=px) | 继承 | |
text-select-position | 水平对齐方式 | select(radioGroup) | 继承 | 可选:left / center / right |
text-select-vertical | 竖直对齐方式 | select(radioGroup) | 继承 | 可选:top / center / bottom |
text-offset-select | 文字偏移 | vector<X,Y>(unit=px) | 继承 | |
font-select-shadow-color | 外发光颜色 | color | 继承 | |
font-select-shadow-blur | 外发光模糊程度 | number(unit=px) | 继承 | |
font-select-shadow-offset | 发光偏移 | vector<X,Y>(unit=px) | 继承 | |
border-select-color | 边框颜色 | color | 继承 | |
border-select-width | 边框宽度 | number(unit=px,min=0) | 继承 | |
border-select-radius | 圆角半径 | number(unit=px,min=0) | 继承 | |
border-select-style | 边框样式 | select(radioGroup) | 继承 | 可选:solid / dashed / dotted / none |
background-select-color | 背景颜色 | color(gradient) | 继承 | |
background-select-image | 背景图/视频 | file | 继承 | |
background-select-fill-type | 填充方式 | select(radioGroup) | 继承 | 可选:stretch / tile / none |
background-select-image-size | 图片比例 | number(unit=%) | 继承 | |
background-select-image-position | 图片位置 | vector<X,Y>(unit=px) | 继承 | |
background-select-blur | 背景模糊 | number(unit=px,min=0) | 继承 | |
background-select-use-nine-patch | 是否使用点九 | boolean | 继承 | |
background-select-nine-patch | 点九编辑 | nine-patch | 继承 |
relationship
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
relationship-field | 关系字段 | string | — | |
relationship-value | 关系值 | string | — |
数据绑定
无组件特有数据绑定字段(纯样式 / 布局 / 装饰)。
事件
触发器
触发器在预览 / 播放态生效(编辑态点击 = 选中组件)。写在本组件
options.interactions的groups[].trigger里。
| 触发器 | 名称 | 触发时机 | payload(供动作公式 {:字段} 取值) |
|---|---|---|---|
click | 点击 | 点击本组件时触发 | 无 |
mouseEnter | 鼠标移入 | 指针移入组件时触发 | 无 |
mouseLeave | 鼠标移出 | 指针移出组件时触发 | 无 |
appear | 入场 | 组件出现时触发(配合进场动画) | 无 |
disappear | 离场 | 组件消失时触发(配合退场动画) | 无 |
receiveBehaviorEvent | 接收行为事件 | 收到 sendBehaviorEvent 动作或宿主 ctx.emit 投递的事件时触发(按 eventName 匹配) | 发送方携带的 data |
动作
触发器命中后执行的动作。本组件既可发起动作(配在自己的交互里),也可作为其它组件动作的目标。
| 动作 | 名称 | 说明 |
|---|---|---|
switchScreen | 切换页面 | 跳转到指定页面 |
switchWindow | 打开 / 关闭窗口 | 开关工程级窗口(弹窗 / 抽屉) |
sendBehaviorEvent | 发送行为事件 | 向目标组件 / 宿主派发自定义事件 |
executeScript | 执行脚本 | 派发命令串,由宿主 onScript 接管 |
editProjectParams | 修改项目参数 | 改项目参数驱动规则 / 条件样式(千人千面) |
requestApi | 调用接口 | 发 HTTP 请求,结果可回写组件 / 参数 |
changeOption | 修改设置 | 把本组件(或其它组件)的某个属性改为静态值 / 公式动态值 |
switchState | 切换状态 | 切到多状态里的某个状态(state:"" 回默认态) |
appear / disappear | 进 / 退场动画 | 对目标 opacity 做 0↔100 插值的显隐动画 |
完整动作清单(switchScreen / switchWindow / openUrl / sendBehaviorEvent / transfer / executeScript / requestApi 等)与持久化写法见事件交互。
示例
{
"type": "basic-button",
"uid": "w_basic_button",
"options": {
"position": [40, 40],
"size": [120, 40]
}
}组合示例:点击按钮 → 修改文本(事件交互)
预览就是播放态:点下面的按钮,右侧文本会被
changeOption动作改写(连点切换两种文案由两组触发器示意)。
对应交互 JSON(写在按钮 options.interactions):
{
"version": 2,
"groups": [
{
"trigger": {
"name": "click",
"options": {}
},
"interactions": [
{
"alias": "点击→改文本",
"enable": true,
"trigger": {
"name": "click",
"options": {}
},
"action": {
"name": "changeOption",
"options": {
"targetElement": "searchElement",
"element": [
{
"targetPath": [
"screen_preview",
"demo_txt"
],
"refType": "element"
}
],
"optionKey": "text",
"text": "✔ 指令已下发,机组启动中…",
"start": "meanwhile",
"delay": 0,
"duration": 1
}
}
}
]
}
]
}