跳到主要内容
button
按钮用于触发一个操作或事件,例如提交表单或关闭对话框,按钮是用于执行操作的可点击对象,按钮内文本/图标表示当用户与其交互时会发生什么,按钮可以有不同的样式,以适应不同的场景。

示例

类型

按钮分为四种类型:primary、secondary、tertiary、ghost。可通过 status 属性,进行切换

PCPhonePad
<page>
<button status="primary" text="primary"/>
<button status="secondary" text="secondary"/>
<button status="tertiary" text="tertiary"/>
<button status="ghost" text="ghost"/>
</page>

export default XPage({
data: {},
show() {}
});


图标按钮

所有的按钮类型都支持定义图标,图标的位置可选择左、右,也可以选择只有图标的按钮

PCPhonePad
<page>
<button status="primary" icon="x-icon-notice-jiahao" text="Create"/>
<button status="secondary" icon="x-icon-action-delete"/>
<button status="tertiary" icon="x-icon-action-uploading" text="Share"/>
</page>

export default XPage({
data: {},
show() {}
});


禁用

PCPhonePad
<page>
<button status="primary" icon="x-icon-universally-a-1zhanweifu" text="primary" disabled />
<button status="secondary" icon="x-icon-universally-a-1zhanweifu" text="secondary" disabled />
<button status="tertiary" icon="x-icon-universally-a-1zhanweifu" text="tertiary" disabled />
<button status="tertiary" icon="x-icon-universally-a-1zhanweifu" text="ghost" disabled />
</page>

export default XPage({
data: {},
show() {}
});


语义按钮

危险按钮(danger)将变为一个属性,所有按钮类型都支持这个属性。danger按钮显示为对删除等破坏性操作的最终确认,这些主要出现在确认模式中。

PCPhonePad
<page>
<button status="primary" text="primary" danger />
<button status="secondary" text="secondary" danger />
<button status="tertiary" text="tertiary" danger />
<button status="ghost" text="ghost" danger />
</page>

export default XPage({
data: {},
show() {}
});


Attributes

属性说明类型可选值默认值版本
type类型Stringbutton/linkbuttonPC/Mobile--
notCabinxTag如果需要用原生标签,可以
使用这个参数,编译器将不会对 button 转成 x-button 。注意,
这个标签只在命令行编译阶段生效,而不是运行阶段,
所以,赋值对他是没有用的
Boolean----PC/Mobile--

Attributes - Button

属性说明类型可选值默认值版本
text名称String----PC/Mobile--
disabled禁用Boolean--falsePC/Mobile--
target同步某组件中的按钮String----PC/Mobile--
status状态Stringprimary/secondary/tertiary/ghost (danger 废弃)secondaryPC/Mobile--
icon左侧图标String----PC/Mobile--
iconRight右侧图标String--------
danger危险按钮(danger,将变为一个属性,所有按钮类型都支持)Boolean--falsePC/Mobile--
loading按钮loading效果0.6.0版本以上支持,0.5版本请参考API 里面loading使用Boolean--falsePC/Mobile--
属性说明类型可选值默认值版本
text名称String----PC/Mobile--
disabled禁用Boolean--falsePC/Mobile--
href链接String----PC/Mobile--

Events

名称说明回调参数版本
click点击--PC/Mobile--