Skip to content

Tabs 标签导航

支持平台

安卓iosweb微信小程序支付宝小程序QQ小程序
xxx

示例

html
<template>
	<t-page title="tabs" class="p.30">
		<t-card title='Tabs 标签导航' class="tdr-tdb-mb.30" sub-title="组织和管理多个页面的切换"></t-card>
		<t-section title='基础使用' class="tdr-tdb-mb.30"></t-section>
		<t-tabs class="tdb-tdr-mb.30" v-if="tabsList2.length>0" :current="current" :tabs="tabsList2"
			@change="ontabschange"></t-tabs>
		<t-section title='禁用滚动+设置主题' class="tdr-tdb-mb.30"></t-section>
		<t-tabs class="tdb-tdr-mb.30" v-if="tabsList1.length>0" type='p' :current="current" :tabs="tabsList1"
			:scrollabel="false"></t-tabs>
		<t-section title='bar样式设置' class="tdr-tdb-mb.30"></t-section>
		<t-tabs class="tdb-tdr-mb.30" v-if="tabsList2.length>0" :current="current" :tabs="tabsList2"
			bar-class="twh.15"></t-tabs>
		<t-section title='滚动条插槽+右侧菜单' class="tdr-tdb-mb.30"></t-section>
		<t-tabs class="tdb-tdr-mb.30" v-if="tabsList1.length>0" rightIcon="list" :current="current" :tabs="tabsList1"
			:scrollabel="false">
			<template v-slot:bar>
				<t-image class="w.30-h.10" src="/static/image/tabsline.png"></t-image>
			</template>
		</t-tabs>

	</t-page>
</template>

<script>
	import { viteApi } from '@/api/uriApi.uts'
	import { TuiTabsOption } from '@/uni_modules/t-ui'
	export default {
		data() {
			return {
				current: 0,
				rowsSize: [['35rpx', '600rpx'], ['35rpx', '300rpx'], ['35rpx', '500rpx'], ['35rpx', '400rpx']],
				tabsList: [] as UTSJSONObject[],
				tabsList1: [] as TuiTabsOption[],
				tabsList2: [] as TuiTabsOption[]
			};
		},
		created() {
			viteApi('testTabslist').then((res) => {
				// this.tabsList = (res['data'] as UTSJSONObject)['list1'] as UTSJSONObject[]
				this.tabsList1 = JSON.parse<TuiTabsOption[]>(JSON.stringify((res['data'] as UTSJSONObject)['list2'] as UTSJSONObject[])) as TuiTabsOption[]
				this.tabsList2 = JSON.parse<TuiTabsOption[]>(JSON.stringify((res['data'] as UTSJSONObject)['list5'] as UTSJSONObject[])) as TuiTabsOption[]
			})
		},
		methods: {
			ontabschange(cur : number) {
				console.log(cur)
			},
			iconClick() {
				uni.showToast({
					title: '点击右侧插槽'
				})
			}
		},
	}
</script>

<style lang=" scss">

</style>

Props

名称描述类型默认值可选值
size标签尺寸String'mini'-
type标签类型String'error'-
tabs标签数据TuiTabsOption[][]-
current当前激活的标签索引Number0-
scrollabel菜单是否可滚动Booleantruetrue, false
itemClass标签项类名String'true'-
barClass标签栏类名String'true'-
rightIcon右侧图标String''-
rightIconClass右侧图标类名String''-

Events

事件名描述回调参数版本
change当标签切换时触发(index: number)-

Slots

名称描述
default标签内容
right右侧内容

Methods

名称描述参数
setBarRect设置标签栏的位置(index: number)
setCurState设置当前标签的状态(index: number)
setCurInstance设置标签实例的状态(index: number, state: boolean)