2018-12-11 19:37:15 +00:00
|
|
|
<template>
|
|
|
|
<div class="p-tabview p-component p-tabview-top">
|
|
|
|
<ul class="p-tabview-nav p-resest" role="tablist">
|
2018-12-11 19:39:08 +00:00
|
|
|
<li role="presentation" v-for="(tab,i) of tabs" :key="tab.header"
|
|
|
|
:class="{'p-highlight': (d_activeTabIndex === i), 'p-disabled': tab.disabled}">
|
2018-12-11 19:53:21 +00:00
|
|
|
<a role="tab" @click="onTabClick($event, tab, i)" @keydown.enter="onTabClick($event, tab, i)">
|
2018-12-11 19:37:15 +00:00
|
|
|
<span class="p-tabview-title">{{tab.header}}</span>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<div class="p-tabview-panels">
|
|
|
|
<slot></slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
activeIndex: {
|
|
|
|
type: Number,
|
|
|
|
default: 0,
|
|
|
|
},
|
|
|
|
orientation: {
|
|
|
|
type: String,
|
|
|
|
default: 'top'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
d_activeTabIndex: this.activeIndex,
|
|
|
|
tabs: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
activeIndex(newValue) {
|
|
|
|
this.activateTab(newValue);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.tabs = this.$children;
|
|
|
|
this.tabs[this.activeIndex].active = true;
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onTabClick(event, tab, index) {
|
2018-12-11 19:39:08 +00:00
|
|
|
if (!tab.disabled) {
|
|
|
|
this.activateTab(index);
|
2018-12-11 19:37:15 +00:00
|
|
|
|
2018-12-11 19:39:08 +00:00
|
|
|
this.$emit('tabchange', {
|
|
|
|
tab: tab,
|
|
|
|
index: index
|
|
|
|
});
|
|
|
|
}
|
2018-12-11 19:37:15 +00:00
|
|
|
},
|
|
|
|
activateTab(index) {
|
|
|
|
this.d_activeTabIndex = index;
|
|
|
|
for (let i = 0; i < this.tabs.length; i++) {
|
|
|
|
this.tabs[i].active = (i === index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|