示例
类型
按钮分为四种类型: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 | 类型 | String | button/link | button | PC/Mobile | -- |
notCabinxTag | 如果需要用原生标签,可以 使用这个参数,编译器将不会对 button 转成 x-button 。注意, 这个标签只在命令行编译阶段生效,而不是运行阶段, 所以,赋值对他是没有用的 | Boolean | -- | -- | PC/Mobile | -- |
Attributes - Button
属性 | 说明 | 类型 | 可选值 | 默认值 | 端 | 版本 |
---|---|---|---|---|---|---|
text | 名称 | String | -- | -- | PC/Mobile | -- |
disabled | 禁用 | Boolean | -- | false | PC/Mobile | -- |
target | 同步某组件中的按钮 | String | -- | -- | PC/Mobile | -- |
status | 状态 | String | primary/secondary/tertiary/ghost (danger 废弃) | secondary | PC/Mobile | -- |
icon | 左侧图标 | String | -- | -- | PC/Mobile | -- |
iconRight | 右侧图标 | String | -- | -- | -- | -- |
danger | 危险按钮(danger,将变为一个属性,所有按钮类型都支持) | Boolean | -- | false | PC/Mobile | -- |
loading | 按钮loading效果0.6.0版本以上支持,0.5版本请参考API 里面loading使用 | Boolean | -- | false | PC/Mobile | -- |
Attributes - Link
属性 | 说明 | 类型 | 可选值 | 默认值 | 端 | 版本 |
---|---|---|---|---|---|---|
text | 名称 | String | -- | -- | PC/Mobile | -- |
disabled | 禁用 | Boolean | -- | false | PC/Mobile | -- |
href | 链接 | String | -- | -- | PC/Mobile | -- |
Events
名称 | 说明 | 回调参数 | 端 | 版本 |
---|---|---|---|---|
click | 点击 | -- | PC/Mobile | -- |