forked from N3-components/N3-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
n3Tab.vue
executable file
·63 lines (60 loc) · 1.01 KB
/
n3Tab.vue
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<template>
<div
:class="classObj"
v-show="show">
<slot></slot>
</div>
</template>
<script>
export default {
props: {
header: {
type: String
},
disabled: {
type: Boolean,
default: false
},
badge: {
type: [String, Number]
},
prefixCls: {
type: String,
default: 'n3'
}
},
data () {
return {
index: 0,
show: false
}
},
computed: {
classObj () {
let {prefixCls, show} = this
let klass = {}
klass[prefixCls + '-tab-pane'] = true
klass[prefixCls + '-tab-hide'] = !show
return klass
},
show () {
return (this.$parent.activeIndex == this.index)
}
},
created () {
this.$parent.renderData.push({
header: this.header,
disabled: this.disabled,
badge: this.badge
})
},
ready () {
for (var c in this.$parent.$children) {
if (this.$parent.$children[c].$el == this.$el) {
this.index = c
break
}
}
}
}
</script>