【发布时间】:2020-02-14 00:28:24
【问题描述】:
有没有办法防止 v-tabs 在被点击时实际发生变化?
在我的情况下,我首先需要检查页面上的内容是否发生了变化,如果有,我想取消切换到另一个选项卡。
event.prevent 和 event.stop 都不会阻止 v-tabs 的变化:
<v-tab @click.prevent.stop="..."> ... </v-tab>
目前我正在使用window.requestAnimationFrame 将选项卡索引重置为旧值。它完成了工作,但这对我来说是一种非常讨厌的技术。
HTML:
<v-tabs v-model="currentIndex">
<v-tab v-for="(route, index) in list" :key="index" @change="handleTabChange(route, $event)" >
{{ route.meta.title }}
</v-tab>
</v-tabs>
TS:
public handleTabChange(routeConf:RouteConfig):void {
let currentIndex:number = this.currentIndex;
window.requestAnimationFrame(() => {
this.currentIndex = currentIndex;
Store.app.router.goto(routeConf.name, null, this.$route.params);
// Once the page actually changes this.currentIndex is set to the correct index..
});
}
【问题讨论】:
-
而不是使用 click.prevent.stop 使用 click.stop.prevent
-
@chans 仍然无法阻止 v-tabs 的变化
标签: vue.js vuetify.js vuetify-tabs