frontend/examking-app/plugins/uview-ui/components/u-tabs-swiper/u-tabs-swiper.vue

(开头部分) 14KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<template>
	<view class="u-tabs" :style="{
			zIndex: zIndex,
			background: bgColor
		}">
		<scroll-view scroll-x class="u-scroll-view" :scroll-left="scrollLeft" scroll-with-animation :style="{ zIndex: zIndex + 1 }">
			<view class="u-tabs-scroll-box" :class="{'u-tabs-scorll-flex': !isScroll}">
				<view class="u-tabs-item" :style="[tabItemStyle(index)]"
				 v-for="(item, index) in getTabs" :key="index" :class="[preId + index]" @tap="emit(index)">
					<u-badge :count="item[count] || item['count'] || 0" :offset="offset" size="mini"></u-badge>
					{{ item[name] || item['name']}}
				</view>
				<view v-if="showBar" class="u-scroll-bar" :style="[tabBarStyle]"></view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import colorGradient from '../../libs/function/colorGradient';
	let color = colorGradient;
	const { windowWidth } = uni.getSystemInfoSync();
	const preId = 'UEl_';

	/**
	 * tabsSwiper 全屏选项卡
	 * @description 该组件内部实现主要依托于uniapp的scroll-view和swiper组件,主要特色是切换过程中,tabsSwiper文字的颜色可以渐变,底部滑块可以 跟随式滑动,活动tab滚动居中等。应用场景可以用于需要左右切换页面,比如商城的订单中心(待收货-待付款-待评价-已退货)等应用场景。
	 * @tutorial https://www.uviewui.com/components/tabsSwiper.html
	 * @property {Boolean} is-scroll tabs是否可以左右拖动(默认true)
	 * @property {Array} list 标签数组,元素为对象,如[{name: '推荐'}]
	 * @property {String Number} current 指定哪个tab为激活状态(默认0)
	 * @property {String Number} height 导航栏的高度,单位rpx(默认80)
	 * @property {String Number} font-size tab文字大小,单位rpx(默认30)
	 * @property {String Number} swiper-width tabs组件外部swiper的宽度,默认为屏幕宽度,单位rpx(默认750)
	 * @property {String} active-color 滑块和激活tab文字的颜色(默认#2979ff)
	 * @property {String} inactive-color tabs文字颜色(默认#303133)
	 * @property {String Number} bar-width 滑块宽度,单位rpx(默认40)
	 * @property {String Number} bar-height 滑块高度,单位rpx(默认6)
	 * @property {Object} bar-style 底部滑块的样式,对象形式
	 * @property {Object} active-item-style 活动tabs item的样式,对象形式
	 * @property {Boolean} show-bar 是否显示底部的滑块(默认true)
	 * @property {String Number} gutter 单个tab标签的左右内边距之和,单位rpx(默认40)
	 * @property {String} bg-color tabs导航栏的背景颜色(默认#ffffff)
	 * @property {String} name 组件内部读取的list参数中的属性名,见官网说明(默认name)
	 * @property {String} count 组件内部读取的list参数中的属性名(badge徽标数),同name属性的使用,见官网说明(默认count)
	 * @property {Array} offset 设置badge徽标数的位置偏移,格式为 [x, y],也即设置的为top和right的值,单位rpx(默认[5, 20])
	 * @property {Boolean} bold 激活选项的字体是否加粗(默认true)
	 * @event {Function} change 点击标签时触发
	 * @example <u-tabs-swiper ref="tabs" :list="list" :is-scroll="false"></u-tabs-swiper>
	 */
	export default {
		name: "u-tabs-swiper",
		props: {
			// 导航菜单是否需要滚动,如只有2或者3个的时候,就不需要滚动了,此时使用flex平分tab的宽度
			isScroll: {
				type: Boolean,
				default: true
			},
			//需循环的标签列表
			list: {
后面还有 428 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。