效果如下图所示
before-leave 切换标签之前的钩子,若返回 false 或者返回 Promise 且被 reject,则阻止切换。
<el-tabs type="border-card" v-model="activeIndex" :before-leave="beforeLeave">
<el-tab-pane name="0">
<span slot="label" style="padding: 8px">
<div class="el-icon-back" style="font-weight: bold;color: rgb(1,171,158)"/>
</span>
</el-tab-pane>
</el-tabs>
beforeLeave(activeIndex, oldActiveIndex) {
if (activeIndex === '0') {
this.$router.back()
return false
}
},
网友评论