Migrated TabView to V3
parent
86360a6df1
commit
50f5fd7bc2
|
@ -1,7 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-tabview-panel" role="tabpanel" v-show="d_active">
|
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -9,18 +7,7 @@ export default {
|
||||||
name: 'tabpanel',
|
name: 'tabpanel',
|
||||||
props: {
|
props: {
|
||||||
header: null,
|
header: null,
|
||||||
active: Boolean,
|
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
d_active: this.active
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
active(newValue) {
|
|
||||||
this.d_active = newValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -1,16 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="p-tabview p-component">
|
<div class="p-tabview p-component">
|
||||||
<ul ref="nav" class="p-tabview-nav" role="tablist">
|
<ul ref="nav" class="p-tabview-nav" role="tablist">
|
||||||
<li role="presentation" v-for="(tab, i) of tabs" :key="tab.header || i" :class="[{'p-highlight': (tab.d_active), 'p-disabled': tab.disabled}]">
|
<li role="presentation" v-for="(tab, i) of tabs" :key="getKey(tab,i)" :class="[{'p-highlight': (d_activeIndex === i), 'p-disabled': isTabDisabled(tab)}]">
|
||||||
<a role="tab" class="p-tabview-nav-link" @click="onTabClick($event, tab)" @keydown="onTabKeydown($event, tab)" :tabindex="tab.disabled ? null : '0'" :aria-selected="tab.d_active" v-ripple>
|
<a role="tab" class="p-tabview-nav-link" @click="onTabClick($event, i)" @keydown="onTabKeydown($event, i)" :tabindex="isTabDisabled(tab) ? null : '0'" :aria-selected="d_activeIndex === i" v-ripple>
|
||||||
<span class="p-tabview-title" v-if="tab.header">{{tab.header}}</span>
|
<span class="p-tabview-title" v-if="tab.props && tab.props.header">{{tab.props.header}}</span>
|
||||||
<TabPanelHeaderSlot :tab="tab" v-if="tab.$scopedSlots.header" />
|
<component :is="tab.children.header" v-if="tab.children && tab.children.header"></component>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li ref="inkbar" class="p-tabview-ink-bar"></li>
|
<li ref="inkbar" class="p-tabview-ink-bar"></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="p-tabview-panels">
|
<div class="p-tabview-panels">
|
||||||
<slot></slot>
|
<div v-for="(tab, i) of tabs" :key="getKey(tab,i)" class="p-tabview-panel" role="tabpanel" v-show="(d_activeIndex === i)">
|
||||||
|
<component :is="tab"></component>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -19,84 +21,63 @@
|
||||||
import DomHandler from '../utils/DomHandler';
|
import DomHandler from '../utils/DomHandler';
|
||||||
import Ripple from '../ripple/Ripple';
|
import Ripple from '../ripple/Ripple';
|
||||||
|
|
||||||
const TabPanelHeaderSlot = {
|
export default {
|
||||||
functional: true,
|
|
||||||
props: {
|
props: {
|
||||||
tab: {
|
activeIndex: {
|
||||||
type: null,
|
type: Number,
|
||||||
default: null
|
default: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render(createElement, context) {
|
|
||||||
return [context.props.tab.$scopedSlots['header']()];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
d_children: []
|
d_activeIndex: this.activeIndex
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
watch: {
|
||||||
this.d_children = this.$children;
|
activeIndex(newValue) {
|
||||||
|
this.d_activeIndex = newValue;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
updated() {
|
updated() {
|
||||||
let activeTab = this.tabs[this.findActiveTabIndex()];
|
this.updateInkBar();
|
||||||
if (!activeTab && this.tabs.length) {
|
},
|
||||||
this.tabs[0].d_active = true;
|
mounted() {
|
||||||
}
|
|
||||||
this.updateInkBar();
|
this.updateInkBar();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onTabClick(event, tab) {
|
onTabClick(event, i) {
|
||||||
if (!tab.disabled && !tab.d_active) {
|
if (!this.isTabDisabled(this.tabs[i]) && i !== this.d_activeIndex) {
|
||||||
this.activateTab(tab);
|
this.d_activeIndex = i;
|
||||||
|
this.$emit('update:activeIndex', this.d_activeIndex);
|
||||||
|
|
||||||
this.$emit('tab-change', {
|
this.$emit('tab-change', {
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
tab: tab
|
index: i
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activateTab(tab) {
|
onTabKeydown(event, i) {
|
||||||
for (let i = 0; i < this.tabs.length; i++) {
|
|
||||||
let active = this.tabs[i] === tab;
|
|
||||||
this.tabs[i].d_active = active;
|
|
||||||
this.tabs[i].$emit('update:active', active);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateInkBar();
|
|
||||||
},
|
|
||||||
onTabKeydown(event, tab) {
|
|
||||||
if (event.which === 13) {
|
if (event.which === 13) {
|
||||||
this.onTabClick(event, tab);
|
this.onTabClick(event, i);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findActiveTabIndex() {
|
|
||||||
for (let i = 0; i < this.tabs.length; i++) {
|
|
||||||
let tab = this.tabs[i];
|
|
||||||
if (tab.d_active) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
updateInkBar() {
|
updateInkBar() {
|
||||||
let tabHeader = this.$refs.nav.children[this.findActiveTabIndex()];
|
let tabHeader = this.$refs.nav.children[this.d_activeIndex];
|
||||||
this.$refs.inkbar.style.width = DomHandler.getWidth(tabHeader) + 'px';
|
this.$refs.inkbar.style.width = DomHandler.getWidth(tabHeader) + 'px';
|
||||||
this.$refs.inkbar.style.left = DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.$refs.nav).left + 'px';
|
this.$refs.inkbar.style.left = DomHandler.getOffset(tabHeader).left - DomHandler.getOffset(this.$refs.nav).left + 'px';
|
||||||
|
},
|
||||||
|
getKey(tab, i) {
|
||||||
|
return tab.props && tab.props.header ? tab.props.header : i;
|
||||||
|
},
|
||||||
|
isTabDisabled(tab) {
|
||||||
|
return tab.props && tab.props.disabled;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
tabs() {
|
tabs() {
|
||||||
return this.d_children.filter(child => child.$vnode.tag.indexOf('tabpanel') !== -1);
|
return this.$slots.default().filter(child => child.type.name === 'tabpanel');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
|
||||||
'TabPanelHeaderSlot': TabPanelHeaderSlot
|
|
||||||
},
|
|
||||||
directives: {
|
directives: {
|
||||||
'ripple': Ripple
|
'ripple': Ripple
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,24 +31,24 @@
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Programmatic</h5>
|
<h5>Programmatic</h5>
|
||||||
<div style="padding: .5rem 0 1rem 0">
|
<div style="padding: .5rem 0 1rem 0" class="p-t-2 p-b-3">
|
||||||
<Button @click="activate(0)" class="p-button-text" label="Activate 1st" />
|
<Button @click="active = 0" class="p-button-text" label="Activate 1st" />
|
||||||
<Button @click="activate(1)" class="p-button-text" label="Activate 2nd" />
|
<Button @click="active = 1" class="p-button-text" label="Activate 2nd" />
|
||||||
<Button @click="activate(2)" class="p-button-text" label="Activate 3rd" />
|
<Button @click="active = 2" class="p-button-text" label="Activate 3rd" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TabView ref="tabview2">
|
<TabView ref="tabview2" v-model:activeIndex="active">
|
||||||
<TabPanel header="Header I" v-model:active="active[0]">
|
<TabPanel header="Header I">
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
||||||
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header II" v-model:active="active[1]">
|
<TabPanel header="Header II">
|
||||||
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
|
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
|
||||||
architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
|
architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
|
||||||
voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.</p>
|
voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.</p>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header III" v-model:active="active[2]">
|
<TabPanel header="Header III">
|
||||||
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati
|
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati
|
||||||
cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
|
cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
|
||||||
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.</p>
|
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.</p>
|
||||||
|
@ -124,7 +124,7 @@ import EventBus from '@/EventBus';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
active: [true, false, false]
|
active: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeout: null,
|
timeout: null,
|
||||||
|
@ -142,15 +142,6 @@ export default {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
EventBus.off('change-theme');
|
EventBus.off('change-theme');
|
||||||
},
|
},
|
||||||
methods: {
|
|
||||||
activate(index) {
|
|
||||||
let activeArray = [...this.active];
|
|
||||||
for (let i = 0 ; i < activeArray.length; i++) {
|
|
||||||
activeArray[i] = (i === index);
|
|
||||||
}
|
|
||||||
this.active = activeArray;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
'TabViewDoc': TabViewDoc
|
'TabViewDoc': TabViewDoc
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ import TabPanel from 'primevue/tabpanel';
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<h5>Active</h5>
|
<h5>Active</h5>
|
||||||
<p>Visibility of the content is specified with the active property that supports one or two-way binding.</p>
|
<p>Visibility of the content is specified with the <i>activeIndex</i> property that supports one or two-way binding.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<TabView>
|
<TabView :activeIndex="activeIndex">
|
||||||
<TabPanel header="Header I">
|
<TabPanel header="Header I">
|
||||||
Content I
|
Content I
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header II" :active="true">
|
<TabPanel header="Header II">
|
||||||
Content II
|
Content II
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header III">
|
<TabPanel header="Header III">
|
||||||
|
@ -40,16 +40,16 @@ import TabPanel from 'primevue/tabpanel';
|
||||||
</TabView>
|
</TabView>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<p>Two-way binding requires the sync operator.</p>
|
<p>Two-way binding requires v-model.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<TabView>
|
<TabView v-model:activeIndex="activeIndex">
|
||||||
<TabPanel header="Header I" :active.sync="active1">
|
<TabPanel header="Header I">
|
||||||
Content I
|
Content I
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header II" :active.sync="active2">
|
<TabPanel header="Header II">
|
||||||
Content II
|
Content II
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header III" :active.sync="active3">
|
<TabPanel header="Header III"">
|
||||||
Content III
|
Content III
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
</TabView>
|
</TabView>
|
||||||
|
@ -74,7 +74,7 @@ import TabPanel from 'primevue/tabpanel';
|
||||||
<h5>Header Template</h5>
|
<h5>Header Template</h5>
|
||||||
<p>Custom content for the title section of a panel is defined using the header template.</p>
|
<p>Custom content for the title section of a panel is defined using the header template.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<TabView class="tabview-custom">
|
<TabView>
|
||||||
<TabPanel>
|
<TabPanel>
|
||||||
<template #header>
|
<template #header>
|
||||||
<i class="pi pi-calendar"></i>
|
<i class="pi pi-calendar"></i>
|
||||||
|
@ -95,11 +95,11 @@ import TabPanel from 'primevue/tabpanel';
|
||||||
<h5>Programmatic Control</h5>
|
<h5>Programmatic Control</h5>
|
||||||
<p>Tabs can be controlled programmatically using active property that defines the active tab.</p>
|
<p>Tabs can be controlled programmatically using active property that defines the active tab.</p>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<Button @click="activate(0)" class="p-button-text" label="Activate 1st" />
|
<Button @click="active = 0" class="p-button-text" label="Activate 1st" />
|
||||||
<Button @click="activate(1)" class="p-button-text" label="Activate 2st" />
|
<Button @click="active = 1" class="p-button-text" label="Activate 2nd" />
|
||||||
<Button @click="activate(2)" class="p-button-text" label="Activate 3st" />
|
<Button @click="active = 2" class="p-button-text" label="Activate 3rd" />
|
||||||
|
|
||||||
<TabView>
|
<TabView v-model:activeIndex="active">
|
||||||
<TabPanel header="Header I" :active.sync="active[0]">
|
<TabPanel header="Header I" :active.sync="active[0]">
|
||||||
Content I
|
Content I
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
@ -117,18 +117,9 @@ import TabPanel from 'primevue/tabpanel';
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
active: [true, false, false]
|
active: 0
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
activate(index) {
|
|
||||||
let activeArray = [...this.active];
|
|
||||||
for (let i = 0 ; i < activeArray.length; i++) {
|
|
||||||
activeArray[i] = (i === index);
|
|
||||||
}
|
}
|
||||||
this.active = activeArray;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
|
@ -150,12 +141,6 @@ export default {
|
||||||
<td>null</td>
|
<td>null</td>
|
||||||
<td>Orientation of tab headers.</td>
|
<td>Orientation of tab headers.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>active</td>
|
|
||||||
<td>boolean</td>
|
|
||||||
<td>null</td>
|
|
||||||
<td>Visibility of the content.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>disabled</td>
|
<td>disabled</td>
|
||||||
<td>boolean</td>
|
<td>boolean</td>
|
||||||
|
@ -259,24 +244,24 @@ export default {
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Programmatic</h5>
|
<h5>Programmatic</h5>
|
||||||
<div style="padding: .5rem 0 1rem 0">
|
<div style="padding: .5rem 0 1rem 0" class="p-t-2 p-b-3">
|
||||||
<Button @click="activate(0)" class="p-button-text" label="Activate 1st" />
|
<Button @click="active = 0" class="p-button-text" label="Activate 1st" />
|
||||||
<Button @click="activate(1)" class="p-button-text" label="Activate 2nd" />
|
<Button @click="active = 1" class="p-button-text" label="Activate 2nd" />
|
||||||
<Button @click="activate(2)" class="p-button-text" label="Activate 3rd" />
|
<Button @click="active = 2" class="p-button-text" label="Activate 3rd" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<TabView>
|
<TabView ref="tabview2" v-model:activeIndex="active">
|
||||||
<TabPanel header="Header I" :active.sync="active[0]">
|
<TabPanel header="Header I">
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
|
||||||
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header II" :active.sync="active[1]">
|
<TabPanel header="Header II">
|
||||||
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
|
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
|
||||||
architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
|
architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione
|
||||||
voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.</p>
|
voluptatem sequi nesciunt. Consectetur, adipisci velit, sed quia non numquam eius modi.</p>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
<TabPanel header="Header III" :active.sync="active[2]">
|
<TabPanel header="Header III">
|
||||||
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati
|
<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati
|
||||||
cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
|
cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio.
|
||||||
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.</p>
|
Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus.</p>
|
||||||
|
@ -346,16 +331,8 @@ export default {
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
active: [true, false, false]
|
active: 0
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
activate(index) {
|
|
||||||
let activeArray = [...this.active];
|
|
||||||
for (let i = 0 ; i < activeArray.length; i++) {
|
|
||||||
activeArray[i] = (i === index);
|
|
||||||
}
|
|
||||||
this.active = activeArray;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
Loading…
Reference in New Issue