refactor(diy-tab): 统一样式绑定语法为数组形式

将模板中的样式绑定从对象展开语法改为数组形式,保持代码风格一致
This commit is contained in:
2026-02-07 16:16:43 +08:00
parent e943b11c8f
commit 5dba8071e4

View File

@@ -1,11 +1,11 @@
<template>
<!-- DIY 标签页组件 - 支持多种样式和位置的标签页切换 -->
<view data-component-name="diy-tab" class="tab-diy-component-preview-container"
:class="[containerClass, styleClass]" :style="containerStyle">
:class="[containerClass, styleClass]" :style="[containerStyle]">
<!-- 顶部标签位置:标签导航 + 指示器 + 内容区域 -->
<template v-if="mergedValue.tabPosition === 'top'">
<!-- 标签导航 -->
<view class="tab-nav" :style="tabNavStyle">
<view class="tab-nav" :style="[tabNavStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getTabKey(tab, idx)" class="tab-item"
:class="{ active: activeTab === idx }"
:style="[tabItemStyle, activeTab === idx ? tabItemActiveStyle : {}]" @tap="switchTab(idx)">
@@ -16,18 +16,20 @@
</view>
<!-- 指示器 -->
<view v-if="mergedValue.showIndicator" class="tab-indicator" :style="{
...indicatorStyle,
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}"></view>
<view v-if="mergedValue.showIndicator" class="tab-indicator" :style="[
indicatorStyle,
{
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}
]"></view>
<!-- 内容区域 -->
<view class="tab-content" :style="contentStyle">
<view class="tab-content" :style="[contentStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getPanelKey(tab, idx)" class="tab-panel"
:class="{ active: activeTab === idx }"
:style="[panelStyle, activeTab === idx ? panelActiveStyle : {}]">
@@ -43,7 +45,7 @@
<!-- 底部标签位置:内容区域 + 指示器 + 标签导航 -->
<template v-else-if="mergedValue.tabPosition === 'bottom'">
<!-- 内容区域 -->
<view class="tab-content" :style="contentStyle">
<view class="tab-content" :style="[contentStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getPanelKey(tab, idx)" class="tab-panel"
:class="{ active: activeTab === idx }"
:style="[panelStyle, activeTab === idx ? panelActiveStyle : {}]">
@@ -55,18 +57,20 @@
</view>
</view>
<!-- 指示器 -->
<view v-if="mergedValue.showIndicator" class="tab-indicator" :style="{
...indicatorStyle,
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}"></view>
<view v-if="mergedValue.showIndicator" class="tab-indicator" :style="[
indicatorStyle,
{
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}
]"></view>
<!-- 标签导航 -->
<view class="tab-nav" :style="tabNavStyle">
<view class="tab-nav" :style="[tabNavStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getTabKey(tab, idx)" class="tab-item"
:class="[{ active: activeTab === idx }, { 'hover-animation': mergedValue.animation }]"
:style="[tabItemStyle, activeTab === idx ? tabItemActiveStyle : {}, tabItemHoverStyle]" @tap="switchTab(idx)">
@@ -81,7 +85,7 @@
<template v-else-if="mergedValue.tabPosition === 'left'">
<view class="tab-layout-horizontal">
<!-- 左侧标签导航 -->
<view class="tab-nav tab-nav-vertical" :style="tabNavStyle">
<view class="tab-nav tab-nav-vertical" :style="[tabNavStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getTabKey(tab, idx)" class="tab-item tab-item-vertical"
:class="[{ active: activeTab === idx }, { 'hover-animation': mergedValue.animation }]"
:style="[tabItemStyle, activeTab === idx ? tabItemActiveStyle : {}, tabItemHoverStyle]" @tap="switchTab(idx)">
@@ -92,18 +96,20 @@
</view>
<!-- 左侧指示器 -->
<view v-if="mergedValue.showIndicator" class="tab-indicator tab-indicator-vertical" :style="{
...indicatorStyle,
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}"></view>
<view v-if="mergedValue.showIndicator" class="tab-indicator tab-indicator-vertical" :style="[
indicatorStyle,
{
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}
]"></view>
<!-- 右侧内容区域 -->
<view class="tab-content" :style="contentStyle">
<view class="tab-content" :style="[contentStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getPanelKey(tab, idx)" class="tab-panel"
:class="{ active: activeTab === idx }"
:style="[panelStyle, activeTab === idx ? panelActiveStyle : {}]">
@@ -121,7 +127,7 @@
<template v-else-if="mergedValue.tabPosition === 'right'">
<view class="tab-layout-horizontal">
<!-- 左侧内容区域 -->
<view class="tab-content" :style="contentStyle">
<view class="tab-content" :style="[contentStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getPanelKey(tab, idx)" class="tab-panel"
:class="{ active: activeTab === idx }"
:style="[panelStyle, activeTab === idx ? panelActiveStyle : {}]">
@@ -134,18 +140,20 @@
</view>
<!-- 右侧指示器 -->
<view v-if="mergedValue.showIndicator" class="tab-indicator tab-indicator-vertical" :style="{
...indicatorStyle,
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}"></view>
<view v-if="mergedValue.showIndicator" class="tab-indicator tab-indicator-vertical" :style="[
indicatorStyle,
{
top: indicatorVars.top,
left: indicatorVars.left,
right: indicatorVars.right,
bottom: indicatorVars.bottom,
width: indicatorVars.width,
height: indicatorVars.height
}
]"></view>
<!-- 右侧标签导航 -->
<view class="tab-nav tab-nav-vertical" :style="tabNavStyle">
<view class="tab-nav tab-nav-vertical" :style="[tabNavStyle]">
<view v-for="(tab, idx) in mergedValue.tabs" :key="getTabKey(tab, idx)" class="tab-item tab-item-vertical"
:class="[{ active: activeTab === idx }, { 'hover-animation': mergedValue.animation }]"
:style="[tabItemStyle, activeTab === idx ? tabItemActiveStyle : {}, tabItemHoverStyle]" @tap="switchTab(idx)">