mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-04 21:18:14 +08:00
67 lines
1.4 KiB
Vue
67 lines
1.4 KiB
Vue
<script>
|
|
import {
|
|
getTransformByIndex,
|
|
getActiveIndex,
|
|
getTransformPropValue,
|
|
getMarginStyle,
|
|
} from './utils'
|
|
export default {
|
|
name: 'TabContent',
|
|
props: {
|
|
animated: { type: Boolean, default: true },
|
|
animatedWithMargin: { type: Boolean, default: true },
|
|
prefixCls: {
|
|
default: 'ant-tabs',
|
|
type: String,
|
|
},
|
|
activeKey: String,
|
|
tabBarPosition: String,
|
|
},
|
|
data () {
|
|
return {
|
|
}
|
|
},
|
|
computed: {
|
|
classes () {
|
|
const { animated, prefixCls } = this
|
|
return {
|
|
[`${prefixCls}-content`]: true,
|
|
[animated
|
|
? `${prefixCls}-content-animated`
|
|
: `${prefixCls}-content-no-animated`]: true,
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
},
|
|
render () {
|
|
const {
|
|
activeKey,
|
|
tabBarPosition, animated, animatedWithMargin, classes,
|
|
} = this
|
|
let style = {}
|
|
if (animated && this.$slots.default) {
|
|
const activeIndex = getActiveIndex(this.$slots.default, activeKey)
|
|
if (activeIndex !== -1) {
|
|
const animatedStyle = animatedWithMargin
|
|
? getMarginStyle(activeIndex, tabBarPosition)
|
|
: getTransformPropValue(getTransformByIndex(activeIndex, tabBarPosition))
|
|
style = animatedStyle
|
|
} else {
|
|
style = {
|
|
display: 'none',
|
|
}
|
|
}
|
|
}
|
|
return (
|
|
<div
|
|
class={classes}
|
|
style={style}
|
|
>
|
|
{this.$slots.default}
|
|
</div>
|
|
)
|
|
},
|
|
}
|
|
</script>
|