From 16213c0f85aa3ac8317797bf4a05fd12940e16d3 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期三, 05 三月 2025 17:29:42 +0800
Subject: [PATCH] -

---
 src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue b/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue
index 57ac88d..1fb1d54 100644
--- a/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue
+++ b/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue
@@ -23,7 +23,9 @@
 							@longpress="longPressHandler(item,index)"
 							:ref="`u-tabs__wrapper__nav__item-${index}`"
 							:style="[addStyle(itemStyle), {flex: scrollable ? '' : 1}]"
-							:class="[`u-tabs__wrapper__nav__item-${index}`, item.disabled && 'u-tabs__wrapper__nav__item--disabled']"
+							:class="[`u-tabs__wrapper__nav__item-${index}`,
+								item.disabled && 'u-tabs__wrapper__nav__item--disabled',
+								innerCurrent == index ? 'u-tabs__wrapper__nav__item-active' : '']"
 						>
 							<slot v-if="$slots.content" name="content" :item="item" :keyName="keyName" :index="index" />
 							<slot v-else-if="!$slots.content && ($slots.default || $slots.$default)"
@@ -93,7 +95,7 @@
 	import { mpMixin } from '../../libs/mixin/mpMixin';
 	import { mixin } from '../../libs/mixin/mixin';
 	import defProps from '../../libs/config/props.js'
-	import { addUnit, addStyle, deepMerge, getPx, sleep, sys } from '../../libs/function/index';
+	import { addUnit, addStyle, deepMerge, getPx, sleep, getWindowInfo } from '../../libs/function/index';
 	/**
 	 * Tabs 鏍囩
 	 * @description tabs鏍囩缁勪欢锛屽湪鏍囩澶氱殑鏃跺�欙紝鍙互閰嶇疆涓哄乏鍙虫粦鍔紝鏍囩灏戠殑鏃跺�欙紝鍙互绂佹婊戝姩銆� 璇ョ粍浠剁殑涓�涓壒鐐规槸閰嶇疆涓烘粴鍔ㄦā寮忔椂锛屾縺娲荤殑tab浼氳嚜鍔ㄧЩ鍔ㄥ埌缁勪欢鐨勪腑闂翠綅缃��
@@ -128,7 +130,11 @@
 				handler (newValue, oldValue) {
 					// 鍐呭閮ㄥ�间笉鐩哥瓑鏃讹紝鎵嶅皾璇曠Щ鍔ㄦ粦鍧�
 					if (newValue !== this.innerCurrent) {
-						this.innerCurrent = newValue
+						if (typeof newValue == 'string') {
+							this.innerCurrent = parseInt(newValue)
+						} else {
+							this.innerCurrent = newValue
+						}
 						this.$nextTick(() => {
 							this.resize()
 						})
@@ -147,7 +153,9 @@
 				return index => {
 					const style = {}
 					// 鍙栧綋鏈熸槸鍚︽縺娲荤殑鏍峰紡
-					const customeStyle = index === this.innerCurrent ? addStyle(this.activeStyle) : addStyle(this.inactiveStyle)
+					const customeStyle = (index == this.innerCurrent)
+						? addStyle(this.activeStyle) 
+						: addStyle(this.inactiveStyle)
 					// 濡傛灉褰撳墠鑿滃崟琚鐢紝鍒欏姞涓婂搴旈鑹诧紝闇�瑕佸湪姝ゅ仛澶勭悊锛屾槸鍥犱负nvue涓嬶紝鏃犳硶鍦╯tyle鏍峰紡涓�氳繃!import瑕嗙洊鏍囩鐨勫唴鑱旀牱寮�
 					if (this.list[index].disabled) {
 						style.color = '#c8c9cc'
@@ -178,7 +186,6 @@
                 // 鑾峰彇涓嬪垝绾跨殑鏁板�紁x琛ㄧず娉�
 				const lineWidth = getPx(this.lineWidth);
 				this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2
-				console.log(lineOffsetLeft)
 				// #ifdef APP-NVUE
 				// 绗竴娆$Щ鍔ㄦ粦鍧楋紝鏃犻渶杩囨浮鏃堕棿
 				this.animation(this.lineOffsetLeft, this.firstTime ? 0 : parseInt(this.duration))
@@ -235,6 +242,9 @@
 			},
 			setScrollLeft() {
 				// 褰撳墠娲诲姩tab鐨勫竷灞�淇℃伅锛屾湁tab鑿滃崟鐨剋idth鍜宭eft(涓哄厓绱犲乏杈圭晫鍒扮埗鍏冪礌宸﹁竟鐣岀殑璺濈)绛変俊鎭�
+				if (this.innerCurrent < 0) {
+                    this.innerCurrent = 0;
+                }
 				const tabRect = this.list[this.innerCurrent]
 				// 绱姞寰楀埌褰撳墠item鍒板乏杈圭殑璺濈
 				const offsetLeft = this.list
@@ -243,7 +253,7 @@
 						return total + curr.rect.width
 					}, 0)
 				// 姝ゅ涓哄睆骞曞搴�
-				const windowWidth = sys().windowWidth
+				const windowWidth = getWindowInfo().windowWidth
 				// 灏嗘椿鍔ㄧ殑tabs-item绉诲姩鍒板睆骞曟涓棿锛屽疄闄呬笂鏄scroll-view鐨勭Щ鍔�
 				let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect
 					.right) / 2 + this.tabsRect.left / 2
@@ -360,9 +370,7 @@
 					&__text {
 						font-size: 15px;
 						color: $u-content-color;
-						/* #ifndef APP-NVUE */
                         white-space: nowrap !important;
-						/* #endif */
 
 						&--disabled {
 							color: $u-disabled-color !important;

--
Gitblit v1.9.1