2017-11-21 11:15:41 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
role="tabpanel"
|
|
|
|
:aria-hidden="active ? 'false' : 'true'"
|
|
|
|
:class="classes"
|
|
|
|
>
|
2017-12-01 11:02:01 +00:00
|
|
|
<slot v-if="isRender || forceRender">
|
2017-11-21 11:15:41 +00:00
|
|
|
</slot>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'TabPane',
|
|
|
|
props: {
|
2017-12-01 04:21:43 +00:00
|
|
|
tabKey: [String, Number],
|
|
|
|
tab: [String, Number, Function],
|
|
|
|
disabled: Boolean,
|
2017-12-01 10:48:16 +00:00
|
|
|
closable: Boolean,
|
2017-12-01 11:02:01 +00:00
|
|
|
forceRender: Boolean,
|
2017-11-21 11:15:41 +00:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
classes () {
|
2017-11-22 07:05:53 +00:00
|
|
|
const { $parent, active } = this
|
|
|
|
const prefixCls = `${$parent.prefixCls}-tabpane`
|
2017-11-21 11:15:41 +00:00
|
|
|
return {
|
|
|
|
[`${prefixCls}`]: true,
|
|
|
|
[`${prefixCls}-inactive`]: !active,
|
|
|
|
[`${prefixCls}-active`]: active,
|
|
|
|
}
|
|
|
|
},
|
2017-11-22 07:05:53 +00:00
|
|
|
active () {
|
|
|
|
const { activeKey } = this.$parent
|
2017-12-01 04:21:43 +00:00
|
|
|
return activeKey === this.tabKey
|
2017-11-22 07:05:53 +00:00
|
|
|
},
|
2017-11-21 11:15:41 +00:00
|
|
|
isRender () {
|
|
|
|
const {
|
2017-11-22 07:05:53 +00:00
|
|
|
active,
|
|
|
|
$parent,
|
2017-11-21 11:15:41 +00:00
|
|
|
} = this
|
2017-11-22 07:05:53 +00:00
|
|
|
const destroyInactiveTabPane = $parent.destroyInactiveTabPane
|
2017-11-21 11:15:41 +00:00
|
|
|
this._isActived = this._isActived || active
|
|
|
|
return destroyInactiveTabPane ? active : this._isActived
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|