我正在使用 vuetify v-tab 组件,每个选项卡代表另一个组件。问题是,在我第一次移动到第二个选项卡时,组件再次刷新。
如何防止刷新?
HTML
<v-tabs v-model="tab">
<v-tab v-for="teamTab in teamTabs" :key="teamTab.index">
<span>{{teamTab.tab }}</span>
</v-tab>
</v-tabs>
<v-tabs-items v-model="tab" >
<v-tab-item v-for="teamTab in teamTabs" :key="teamTab.index">
<team-history
v-show="tab==0"
:team="TeamName"
@WaitingIcon="waitingIcon? waitingIcon=false : waitingIcon=true"
:key="componentKey"
></team-history>
<team-actions
v-show="tab==1"
@waitingIcon="waitingIcon? waitingIcon=false : waitingIcon=true"
@historyTab="tab=0"
:team="TeamName"
:key="componentKey"
></team-actions>
</v-tab-item>
</v-tabs-items>
脚本
export default {
components: { TeamActions, TeamHistory },
name: "TeamManagement",
data: () => ({
team: "",
waitingIcon: false,
tab: 0,
componentKey: 0,
teamTabs: [{ tab: "History" }, { tab: "Run Process" }]
})
};