parent
c9985ada18
commit
5b143a2b3f
3 changed files with 22 additions and 39 deletions
|
@ -1,48 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<Tabs type="card" :animated="true" closable @on-tab-remove="handleTabRemove" :beforeRemove="handleBeforeRemove">
|
<div>
|
||||||
<Wrapper>
|
<Button @click="showSecond = !showSecond">change</Button>
|
||||||
<TabPane label="标签一" v-if="tab0">标签一的内容</TabPane>
|
<Tabs value="name1">
|
||||||
<TabPane label="标签二" v-if="tab1">标签二的内容</TabPane>
|
<TabPane label="标签一" name="name1" :index="1">标签一的内容</TabPane>
|
||||||
<TabPane label="标签三" v-if="tab2">标签三的内容</TabPane>
|
<TabPane label="标签二" name="name2" :index="2" v-if="showSecond">标签二的内容</TabPane>
|
||||||
</Wrapper>
|
<TabPane label="标签三" name="name3" :index="3">标签三的内容</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
</div>
|
||||||
<!--<Tabs type="card" :animated="true" closable @on-tab-remove="handleTabRemove" :beforeRemove="handleBeforeRemove">-->
|
|
||||||
<!--<TabPane label="标签一" v-if="tab0">标签一的内容</TabPane>-->
|
|
||||||
<!--<TabPane label="标签二" v-if="tab1">标签二的内容</TabPane>-->
|
|
||||||
<!--<TabPane label="标签三" v-if="tab2">标签三的内容</TabPane>-->
|
|
||||||
<!--</Tabs>-->
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Wrapper from '../components/wrapper.vue';
|
|
||||||
export default {
|
export default {
|
||||||
components: { Wrapper },
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
tab0: true,
|
showSecond: false
|
||||||
tab1: true,
|
|
||||||
tab2: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
handleTabRemove (name) {
|
|
||||||
this['tab' + name] = false;
|
|
||||||
},
|
|
||||||
handleBeforeRemove (index) {
|
|
||||||
console.log(index);
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this.$Modal.confirm({
|
|
||||||
title: 'Title',
|
|
||||||
content: '<p>Content of dialog</p><p>Content of dialog</p>',
|
|
||||||
onOk: () => {
|
|
||||||
resolve();
|
|
||||||
},
|
|
||||||
onCancel: () => {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,11 @@
|
||||||
tab: {
|
tab: {
|
||||||
type: String
|
type: String
|
||||||
},
|
},
|
||||||
|
// 在 TabPane 使用 v-if 时,并不会按照预先的顺序渲染,这时可设置 index,并从小到大排序
|
||||||
|
// 数值需大于 0
|
||||||
|
index: {
|
||||||
|
type: Number
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -187,6 +187,14 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 在 TabPane 使用 v-if 时,并不会按照预先的顺序渲染,这时可设置 index,并从小到大排序
|
||||||
|
TabPanes.sort((a, b) => {
|
||||||
|
if (a.index && b.index) {
|
||||||
|
return a.index > b.index ? 1 : -1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
return TabPanes;
|
return TabPanes;
|
||||||
},
|
},
|
||||||
updateNav () {
|
updateNav () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue