Skip to content
本页导读

Button 按钮

组件类型:UxButtonComponentPublicInstance

支持多种主题按钮、镂空按钮,可配置加载中状态,可开启节流等功能

平台兼容性

AndroidiOSweb鸿蒙 Next小程序
xx

Props

属性名类型默认值说明
themeString'info'按钮类型
textString-按钮文字
colorString-按钮文字颜色
darkColorString-深色
sizeNumber$ux.Conf.fontSize按钮文字大小
boldBooleanfalse按钮文字加粗
backgroundString-按钮背景颜色
cornerNumber5圆角
plainBooleanfalse是否镂空
loadingBooleanfalse显示加载中
loadingTypeString'spinner'loading类型
loadingTextString'加载中...'加载中文字
loadingSizeNumber$ux.Conf.fontSize加载中文字大小
loadingColorString$ux.Conf.placeholderColor加载中颜色
iconString-按钮图标
iconSizeNumber$ux.Conf.fontSize图标大小
iconColorString-图标文字颜色
customFontString-自定义字体路径
customFamilyString-自定义字体family
directionString'row'布局方向
pathString-点击跳转的页面路径
throttleTimeNumber0节流,一定时间内只能触发一次,单位毫秒
hoverStartTimeNumber-点击态出现时间,单位毫秒
hoverStayTimeNumber100点击态保留时间,单位毫秒
hoverBooleantrue是否显示点击态
stopPropagationBooleanfalse阻止向上冒泡
disabledBooleanfalse是否禁用

theme

说明
text文字
info默认
primary主要
success成功
warning警告
error错误

darkColor

说明
none不显示
auto自动适配深色模式
color其他颜色

loadingType

说明
circular圆环
spinner菊花

direction

说明
row水平布局
column垂直布局

Events

事件名说明参数
click点击事件event: MouseEvent
longpress长按事件event: TouchEvent
touchstart手指触摸动作开始事件event: TouchEvent
touchend手指触摸动作结束事件event: TouchEvent
touchmove手指触摸动作移动事件event: TouchEvent
touchcancel手指触摸动作被打断事件event: TouchEvent

示例代码

html
<template>
	<ux-page>
		<ux-navbar :title="title" :border="false"></ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag" title="按钮" :bold="true">
				<ux-text text="支持多种主题按钮、镂空按钮,可配置加载中状态,可开启节流等功能"></ux-text>
				<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
					<ux-text text="详细文档:"></ux-text>
					<ux-text style="flex: 1" name="按钮" text="https://www.uxframe.cn/component/basic/button.html" mode="link"></ux-text>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
				<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
				<ux-row>
					<ux-button theme="info" text="默认" :mr="10"></ux-button>
					<ux-button theme="primary" text="主要" :mr="10"></ux-button>
					<ux-button theme="success" text="成功" :mr="10"></ux-button>
					<ux-button theme="warning" text="警告" :mr="10"></ux-button>
					<ux-button theme="error" text="错误" :mr="10"></ux-button>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="镂空按钮" :bold="true">
				<ux-text text="支持镂空按钮,适配暗黑模式" :mb="15"></ux-text>
				<ux-col>
					<ux-button :plain="true" theme="info" text="默认"></ux-button>
					<ux-button :plain="true" theme="primary" text="主要" :mt="10"></ux-button>
					<ux-button :plain="true" theme="success" text="成功" :mt="10"></ux-button>
					<ux-button :plain="true" theme="warning" text="警告" :mt="10"></ux-button>
					<ux-button :plain="true" theme="error" text="错误" :mt="10"></ux-button>
					<ux-button :plain="true" theme="text" text="文字"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自定义样式" :bold="true">
				<ux-text text="支持配置图标、加载状态、圆角、背景色" :mb="15"></ux-text>
				<ux-col>
					<ux-button :corner="20" theme="error" text="圆角按钮"></ux-button>
					<ux-button theme="primary" :loading="true" loadingText="请稍候..." loadingColor="white" :mt="10"></ux-button>
					<ux-button theme="success" :useIcons="true" icon="click-outline" text="带图标" color="white" :mt="10"></ux-button>
					<ux-button theme="warning" background="#a900a9" text="背景色" :mt="10"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="禁用按钮" :bold="true">
				<ux-text text="支持禁用按钮,适配暗黑模式" :mb="15"></ux-text>
				<ux-col>
					<ux-button :disabled="true" theme="info" text="默认"></ux-button>
					<ux-button :disabled="true" theme="primary" text="主要" :mt="10"></ux-button>
					<ux-button :disabled="true" theme="success" text="成功" :mt="10"></ux-button>
					<ux-button :disabled="true" :plain="true" theme="warning" text="警告" :mt="10"></ux-button>
					<ux-button :disabled="true" :plain="true" theme="error" text="错误" :mt="10"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="功能" :bold="true">
				<ux-text text="支持节流、跳转页面、阻止冒泡等功能" :mb="15"></ux-text>
				<ux-row>
					<ux-button theme="info" :throttleTime="200" text="开启节流" :mr="10"></ux-button>
					<ux-button theme="info" :throttleTime="200" path="/pages/component/basic/text/text?title=From Button按钮" text="跳转页面" :mr="10"></ux-button>
					<ux-button theme="info" :stopPropagation="true" text="阻止冒泡"></ux-button>
				</ux-row>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
<template>
	<ux-page>
		<ux-navbar :title="title" :border="false"></ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag" title="按钮" :bold="true">
				<ux-text text="支持多种主题按钮、镂空按钮,可配置加载中状态,可开启节流等功能"></ux-text>
				<ux-row :flex="true" align="top" :mt="5" style="width: 100%;">
					<ux-text text="详细文档:"></ux-text>
					<ux-text style="flex: 1" name="按钮" text="https://www.uxframe.cn/component/basic/button.html" mode="link"></ux-text>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="主题" :bold="true">
				<ux-text text="多种主题可配置,适配暗黑模式" :mb="15"></ux-text>
				<ux-row>
					<ux-button theme="info" text="默认" :mr="10"></ux-button>
					<ux-button theme="primary" text="主要" :mr="10"></ux-button>
					<ux-button theme="success" text="成功" :mr="10"></ux-button>
					<ux-button theme="warning" text="警告" :mr="10"></ux-button>
					<ux-button theme="error" text="错误" :mr="10"></ux-button>
				</ux-row>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="镂空按钮" :bold="true">
				<ux-text text="支持镂空按钮,适配暗黑模式" :mb="15"></ux-text>
				<ux-col>
					<ux-button :plain="true" theme="info" text="默认"></ux-button>
					<ux-button :plain="true" theme="primary" text="主要" :mt="10"></ux-button>
					<ux-button :plain="true" theme="success" text="成功" :mt="10"></ux-button>
					<ux-button :plain="true" theme="warning" text="警告" :mt="10"></ux-button>
					<ux-button :plain="true" theme="error" text="错误" :mt="10"></ux-button>
					<ux-button :plain="true" theme="text" text="文字"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自定义样式" :bold="true">
				<ux-text text="支持配置图标、加载状态、圆角、背景色" :mb="15"></ux-text>
				<ux-col>
					<ux-button :corner="20" theme="error" text="圆角按钮"></ux-button>
					<ux-button theme="primary" :loading="true" loadingText="请稍候..." loadingColor="white" :mt="10"></ux-button>
					<ux-button theme="success" :useIcons="true" icon="click-outline" text="带图标" color="white" :mt="10"></ux-button>
					<ux-button theme="warning" background="#a900a9" text="背景色" :mt="10"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="禁用按钮" :bold="true">
				<ux-text text="支持禁用按钮,适配暗黑模式" :mb="15"></ux-text>
				<ux-col>
					<ux-button :disabled="true" theme="info" text="默认"></ux-button>
					<ux-button :disabled="true" theme="primary" text="主要" :mt="10"></ux-button>
					<ux-button :disabled="true" theme="success" text="成功" :mt="10"></ux-button>
					<ux-button :disabled="true" :plain="true" theme="warning" text="警告" :mt="10"></ux-button>
					<ux-button :disabled="true" :plain="true" theme="error" text="错误" :mt="10"></ux-button>
				</ux-col>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="功能" :bold="true">
				<ux-text text="支持节流、跳转页面、阻止冒泡等功能" :mb="15"></ux-text>
				<ux-row>
					<ux-button theme="info" :throttleTime="200" text="开启节流" :mr="10"></ux-button>
					<ux-button theme="info" :throttleTime="200" path="/pages/component/basic/text/text?title=From Button按钮" text="跳转页面" :mr="10"></ux-button>
					<ux-button theme="info" :stopPropagation="true" text="阻止冒泡"></ux-button>
				</ux-row>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="wink" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
ts
<script setup>
	let title = ''
	
	onLoad((e: OnLoadOptions) => {
		title = e['title'] ?? ''
	})
</script>
<script setup>
	let title = ''
	
	onLoad((e: OnLoadOptions) => {
		title = e['title'] ?? ''
	})
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>