Skip to content
本页导读

Tabs

组件类型:UxTabsComponentPublicInstance

支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
leftSlot左插槽
rightSlot右插槽
themeStringinfo按钮类型
modelValueNumber0双向绑定值
datasUxTab[]tabs列表
typeStringline类型
animStringscroll动效类型
anchorIdString锚点ScrollId
anchorBooleanfalse自动滚动到锚点
widthAnyauto宽度
heightAny44高度
cornerAny0圆角
selectedColorString$ux.Conf.fontColor选中颜色
unselectedColorString$ux.Conf.fontColor未选中颜色
backgroundString$ux.Conf.backgroundColor背景色
backgroundDarkString深色none-不显示,auto-自动适配深色模式,其他-颜色
lineColorString线颜色selectedColor优先级更高
lineWidthAny20线宽度0则自动适配
lineHeightAny2线高度、点直径
fontSizeAny$ux.Conf.fontSize字体大小
selectSizeAny$ux.Conf.fontSize选中字体大小
boldBooleanfalse字体加粗
selectBoldBooleanfalse选中字体加粗
paddingAny12内部padding
durationNumber300过渡时间
offsetAny0锚点偏移距离

theme

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

type

说明
none无
line下划线
point点
smile微笑

anim

说明
none无
scroll左右滚动
push左右推压

backgroundDark

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

Events

事件名说明参数
change当前选择下标改变时触发
anchor当要滚动目标时触发

示例代码

html
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="选项卡导航栏" :bold="true">
				<ux-text text="支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="左右滚动" :bold="true">
				<ux-tabs v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="左右推压" :bold="true">
				<ux-tabs anim="push" theme="success" :select-size="15" :line-width="0" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="微笑" :bold="true">
				<ux-tabs type="smile" :select-bold="true" selected-color="red" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="点" :bold="true">
				<ux-tabs type="point" theme="warning" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			 <ux-card direction="column" icon="arrowright" title="左右插槽" :bold="true">
				<ux-tabs v-model="tabIndex" :datas="tabs">
					<template #left>
						<ux-button theme="primary" :ml="10" text="菜单1"></ux-button>
					</template>
					<template #right>
						<ux-button theme="warning" :mr="10" text="菜单2"></ux-button>
					</template>
				</ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自定义宽度、颜色、圆角" :bold="true">
				<ux-tabs :width="200" :height="38" :corner="22" background="#00a900" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
<template>
	<ux-page :stack="showDoc">
		<ux-navbar :title="title" :border="false">
			<template v-slot:right>
				<!-- #ifndef MP -->
				<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
				<!-- #endif -->
			</template>
		</ux-navbar>
		
		<ux-scroll>
			<ux-card direction="column" icon="flag-filled" title="选项卡导航栏" :bold="true">
				<ux-text text="支持点、下划线、微笑类型,下划线支持左右滚动、左右推压效果"></ux-text>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="左右滚动" :bold="true">
				<ux-tabs v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="左右推压" :bold="true">
				<ux-tabs anim="push" theme="success" :select-size="15" :line-width="0" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="微笑" :bold="true">
				<ux-tabs type="smile" :select-bold="true" selected-color="red" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="点" :bold="true">
				<ux-tabs type="point" theme="warning" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			 <ux-card direction="column" icon="arrowright" title="左右插槽" :bold="true">
				<ux-tabs v-model="tabIndex" :datas="tabs">
					<template #left>
						<ux-button theme="primary" :ml="10" text="菜单1"></ux-button>
					</template>
					<template #right>
						<ux-button theme="warning" :mr="10" text="菜单2"></ux-button>
					</template>
				</ux-tabs>
			</ux-card>
			
			<ux-card direction="column" icon="arrowright" title="自定义宽度、颜色、圆角" :bold="true">
				<ux-tabs :width="200" :height="38" :corner="22" background="#00a900" v-model="tabIndex" :datas="tabs"></ux-tabs>
			</ux-card>
			
			<ux-placeholder :height="200">
				<ux-row justify="center" align="center" style="height: 100%;">
					<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
				</ux-row>
			</ux-placeholder>
		</ux-scroll>
	</ux-page>
</template>
ts
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	import { UxTab } from '@/uni_modules/ux-frame'
	
	const title = ref('')
	
	const tabs = [
		{
			name: 'Tab1',
		},
		{
			name: 'Tab2 加长版',
			badge: 10
		},
		{
			name: 'Tab3',
		},
		{
			name: 'Tab4',
			badge: 10,
			reddot: true
		},
		{
			name: 'Tab5 加长版',
		},
		{
			name: 'Tab6',
		},
		{
			name: 'Tab7',
		},
		{
			name: '被禁用',
			disabled: true
		}
	] as UxTab[]
	
	const tabIndex = ref(0)
	
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/tabs.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
</script>
<script setup>
	
	import * as plus from '@/uni_modules/ux-plus'
	import { UxTab } from '@/uni_modules/ux-frame'
	
	const title = ref('')
	
	const tabs = [
		{
			name: 'Tab1',
		},
		{
			name: 'Tab2 加长版',
			badge: 10
		},
		{
			name: 'Tab3',
		},
		{
			name: 'Tab4',
			badge: 10,
			reddot: true
		},
		{
			name: 'Tab5 加长版',
		},
		{
			name: 'Tab6',
		},
		{
			name: 'Tab7',
		},
		{
			name: '被禁用',
			disabled: true
		}
	] as UxTab[]
	
	const tabIndex = ref(0)
	
	const showDoc = ref(false)
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/tabs.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
</script>
css
<style lang="scss">
	
</style>
<style lang="scss">
	
</style>