【发布时间】:2019-09-11 15:00:48
【问题描述】:
我创建了两个选项卡,默认情况下我希望第一个<li> 上的活动集类。
Then, when the second tab is selected, the .active class should pass to the second <li> and be removed from the first.
我可以使用 CSS 来创建一些样式规则,以便直观地指示哪个选项卡当前处于活动状态。
我还创建了一个JS Fiddle 来查看当前输出。
欢迎任何帮助,因为我有点卡住了。
<ul class="overlay-panel-actions-primary">
<li v-for="(tab, index) in tabs" @click="currentTab = index">{{tab}}</li>
</ul>
<div class="content-bd">
<div class="tab-content">
<div v-show="currentTab === 0">
List of filters options
</div>
<div v-show="currentTab === 1">
List of sort options
</div>
</div>
</div>
new Vue({
el: "#app",
data() {
return {
currentTab: 0,
tabs: ['Filter', 'Sort']
};
},
})
【问题讨论】:
-
您可以在您的样式中使用
.exact-active-class类,无需在您的 JS 或 JSX 中做任何事情
标签: javascript vue.js vuejs2 v-for