ant-design-vue/components/vc-tabs/src/TabPane.jsx

54 lines
1.2 KiB
Vue
Raw Normal View History

2018-03-19 02:16:27 +00:00
2017-11-21 11:15:41 +00:00
export default {
name: 'TabPane',
props: {
2018-01-19 03:47:06 +00:00
tab: [String, Number, Function, Array, Object],
2017-12-01 04:21:43 +00:00
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-08 03:46:53 +00:00
return activeKey === this.$vnode.key
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: {
},
2018-01-19 03:47:06 +00:00
render () {
const { active, classes, $slots, isRender, forceRender } = this
return (
<div
role='tabpanel'
aria-hidden={active ? 'false' : 'true'}
class={classes}
>
{isRender || forceRender ? $slots.default : null}
</div>
)
},
2017-11-21 11:15:41 +00:00
}
2018-03-19 02:16:27 +00:00