tabs.vue
1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<template>
<Row>
<Col :span="12">
<Tabs type="card" closable @on-tab-remove="handleTagRemove">
<Tab-pane label="标签一" v-if="tab0">标签一的内容</Tab-pane>
<Tab-pane label="标签二" v-if="tab1">标签二的内容</Tab-pane>
<Tab-pane label="标签三" v-if="tab2">标签三的内容</Tab-pane>
</Tabs>
</Col>
<Col :span="12">
<Tabs type="card" closable @on-tab-remove="handleTagRemove">
<Tab-pane :label="tab.label" v-for="tab of tabs">{{tab.content}}</Tab-pane>
<Button size="small" slot="right" @click="addTab">添加</Button>
</Tabs>
</Col>
</Row>
</template>
<script lang="babel">
export default {
data () {
return {
tabs:[
{label:'标签0',content:'标签内容0'},
{label:'标签1',content:'标签内容1'},
{label:'标签2',content:'标签内容2'},
],
tab0: true,
tab1: true,
tab2: true
}
},
methods: {
handleTagRemove (name) {
this['tab' + name] = false;
},
addTab(){
this.tabs.push({label:'标签'+this.tabs.length,content:'标签内容'+this.tabs.length});
}
}
}
</script>