From d3e6dd6b3032c119676efa1e9fcee3a8a8043fc5 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期五, 07 三月 2025 13:40:44 +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