Skip to content
加载中...

T-Button 按钮

兼容端

安卓苹果Web鸿蒙微信小程序

使用示例

vue
<template>
	<t-navbar title="按钮组件" :is-back="true"></t-navbar>
	<t-page :loading="state.loading">
		<t-card :ma="['8','15']" title="主要按钮">
			<t-button type="default" :ma="['0','0','15','0']">默认按钮</t-button>
			<t-button type="primary" :ma="['0','0','15','0']">主题按钮</t-button>
			<t-button type="error" :ma="['0','0','15','0']">错误按钮</t-button>
			<t-button type="success" :ma="['0','0','15','0']">成功按钮</t-button>
			<t-button type="warning" :ma="['0','0','15','0']">警告按钮</t-button>
		</t-card>
		<t-card :ma="['8','15']" title="次要按钮">
			<t-button type="default" :secondary="true" :ma="['0','0','15','0']">默认按钮</t-button>
			<t-button type="primary" :secondary="true" :ma="['0','0','15','0']">主题按钮</t-button>
			<t-button type="error" :secondary="true" :ma="['0','0','15','0']">错误按钮</t-button>
			<t-button type="success" :secondary="true" :ma="['0','0','15','0']">成功按钮</t-button>
			<t-button type="warning" :secondary="true" :ma="['0','0','15','0']">警告按钮</t-button>
		</t-card>
		<t-card :ma="['8','15']" title="镂空">
			<t-button :sidelines="true" type="default"  :ma="['0','0','15','0']">默认按钮</t-button>
			<t-button :sidelines="true" type="primary"  :ma="['0','0','15','0']">主题按钮</t-button>
			<t-button :sidelines="true" type="error" :ma="['0','0','15','0']">错误按钮</t-button>
			<t-button :sidelines="true" type="success" :ma="['0','0','15','0']">成功按钮</t-button>
			<t-button :sidelines="true" type="warning" :ma="['0','0','15','0']">警告按钮</t-button>
		</t-card>
		<t-card title="尺寸" :ma="['8','15']">
			<t-button type="primary" size="tiny" :ma="['0','0','15','0']" :block="false">tiny按钮</t-button>
			<t-button type="primary" size="small" :ma="['0','0','15','0']" :block="false">small按钮</t-button>
			<t-button type="primary" size="medium"  :ma="['0','0','15','0']" :block="false">medium按钮</t-button>
			<t-button type="primary" size="large" :ma="['0','0','15','0']" :block="false">large按钮</t-button>
		</t-card>
		<t-card title="图标" :ma="['8','15']">
			<t-button icon="home-fill" type="primary" :ma="['0','0','15','0']">主题按钮</t-button>
			<t-button icon="home-fill" icon-direction="right" type="success" :ma="['0','0','15','0']">主题按钮</t-button>
		</t-card>
		<t-card title="插槽" :ma="['8','15']">
			<t-button type="primary" :ma="['0','0','15','0']">
				<template v-slot:left>
					<t-image width="20" height="20" src="/static/logo.png"></t-image>
				</template>
				<template v-slot:default>左插槽按钮</template>
			</t-button>
			<t-button icon-direction="right" type="success" :ma="['0','0','15','0']">
				<template v-slot:right>
					<t-image width="20" height="20" src="/static/logo.png"></t-image>
				</template>
				<template v-slot:default>右插槽按钮</template>
			</t-button>
		</t-card>
		<t-card title="块级" :ma="['8','15']">
			<t-button type="primary" :ma="['0','0','15','0']" :block="false">块级按钮</t-button>
		</t-card>
		<t-card title="自定义样式" :ma="['8','15']">
			<t-button bgColor="#f81f81" :sidelines="true" :ma="['0','0','15','0']" :block="false">边线按钮</t-button>
			<t-button bgColor="#f81f81" :secondary="true" :ma="['0','0','15','0']" :block="false">次要按钮</t-button>
			<t-button bgColor="#f81f81" color="#ffffff" :ma="['0','0','15','0']" :block="false">背景色按钮</t-button>
			<t-button bgColor="#f81f81" color="#ffffff" :round="['25','25']" :ma="['0','0','15','0']" :block="false">圆角按钮</t-button>
		</t-card>
	</t-page>
</template>

<script setup lang="uts">
	type stateType = {
		loading: boolean
	}
	const state = reactive<stateType>({
		loading: false
	} as stateType)
	
	onReady(() => {
		state.loading = true
	})
</script>

属性

属性名类型默认值说明
typeString"default"按钮主题类型,可选值:default/primary/error/success/warning
roundArray<string>['10','10']圆角大小
borderString""边线样式
widthString"auto"按钮宽度
heightString"45"按钮高度
bgColorString""背景颜色
colorString"#333333"文字颜色
fontSizeString"15"文字大小
blockBooleantrue是否为块级按钮
sizeString""按钮尺寸,可选值:tiny/small/medium/large
linkBooleanfalse是否为链接模式
linkModeString"navigateTo"链接模式,可选值:navigateTo/redirectTo/reLaunch/switchTab/navigateBack
linkTypeString""链接动画类型
linkAnimationDurationNumber0链接动画时长(ms)
linkUrlString""链接地址
maArray<string>['0','0']margin值
paArray<string>['0','0']padding值
iconString""图标名称
iconDirectionString"left"图标方向,可选值:left/right
iconColorString"#ffffff"图图标颜色
iconSizeString"18"图标大小
iconDarkBooleanfalse是否开启图标暗黑模式自适应
sidelinesBooleanfalse是否为边线/镂空样式
secondaryBooleanfalse是否为次要按钮
darkBooleantrue是否为暗黑模式自适应

方法

方法名说明
click按钮点击事件

插槽

插槽名说明
default按钮文本内容
left左侧图标插槽
right右侧图标插槽