<el-tabs v-model="tabMenu" class="tabs-menu" :before-leave="tabChange"> <el-tab-pane v-for="item in nemuList" :key="item.id" :label="item.name" :name="item.id" > <template #label> <div :class="delay==item.id?'disabled':'able'">{{item.name}}</div> </template> <component :is="item.component" :my-detail="detail" ></component> </el-tab-pane> </el-tabs>
label要写在插槽里。这样方便单独为某一个tab加样式
const nemuList = shallowRef([{ name: '申请', id: 0, component: Apply }, { name: '资料审核', id: 1, component: DataReview }, { name: '初评', id: 2, component: InitReview }, { name: '复评', id: 3, component: FinalReview } ]); const tabMenu = ref(0); const delay=ref([2,3]);//禁止点击的tab
const tabChange = (activeName,oldActiveName) => { tabMenu.value=activeName; if(delay.value==tabMenu.value){ console.log("禁止点击") return false; } }
给禁止点击的tab添加上样式就行啦
.disabled{ color:#bdbbbb; }