mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
* fix: Tabbar icon line-height * [new feature] progress add showPivot prop * [new feature] TabItem support vue-router * [new feature] update document header style * [Doc] add toast english ducoment * [bugfix] Search box-sizing wrong * [Doc] update vant-demo respo * [Doc] translate theme & demo pages * [Doc] add Internationalization document * [bugfix] remove unnecessary props * [fix] optimize clickoutside * [new feature] optimize find-parent * [new feature]: change document title accordinng to language * [new feature] Pagination code review * [improvement] adjust icon-font unicode * [improvement] Icon spinner color inherit * [improvement] icon default width * [bugfix] DateTimePicker validate date props * [bugfix] Tab item text ellipsis * [improvement] optimize single line ellipsis * [Improvement] optimzie staticClass
66 lines
1.2 KiB
Vue
66 lines
1.2 KiB
Vue
<template>
|
|
<div class="van-tab__pane" :class="{ 'van-tab__pane--select': key === $parent.curActive }">
|
|
<slot></slot>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import findParent from '../mixins/find-parent';
|
|
|
|
export default {
|
|
name: 'van-tab',
|
|
|
|
mixins: [findParent],
|
|
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
disabled: Boolean
|
|
},
|
|
|
|
data() {
|
|
this.findParentByName('van-tabs');
|
|
const nextIndex = this.parentGroup.tabs.length;
|
|
this.updateParentData(nextIndex);
|
|
return {
|
|
key: nextIndex
|
|
};
|
|
},
|
|
|
|
watch: {
|
|
title() {
|
|
this.updateParentData();
|
|
},
|
|
disabled() {
|
|
this.updateParentData();
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
updateParentData(nextIndex) {
|
|
const index = arguments.length ? nextIndex : this.key;
|
|
this.parentGroup.tabs.splice(index, 1, {
|
|
title: this.title,
|
|
disabled: this.disabled,
|
|
index
|
|
});
|
|
}
|
|
},
|
|
|
|
destroyed() {
|
|
const key = this.key;
|
|
const tabs = this.parentGroup.tabs;
|
|
|
|
for (let i = 0; i < tabs.length; i++) {
|
|
/* istanbul ignore else */
|
|
if (tabs[i].index === key) {
|
|
this.parentGroup.tabs.splice(i, 1);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|