mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* style: use prettier * style: just prettier format, no code changes * style: eslint fix object-shorthand, prefer-const * style: fix no-void * style: no-console
42 lines
940 B
Vue
42 lines
940 B
Vue
<template>
|
|
<section class="el-container" :class="{ 'is-vertical': isVertical }">
|
|
<slot></slot>
|
|
</section>
|
|
</template>
|
|
<script lang="ts">
|
|
import { defineComponent, computed } from 'vue'
|
|
|
|
import type { Component, VNode } from 'vue'
|
|
|
|
export default defineComponent({
|
|
name: 'ElContainer',
|
|
props: {
|
|
direction: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
},
|
|
setup(props, { slots }) {
|
|
const isVertical = computed(() => {
|
|
if (props.direction === 'vertical') {
|
|
return true
|
|
} else if (props.direction === 'horizontal') {
|
|
return false
|
|
}
|
|
if (slots && slots.default) {
|
|
const vNodes: VNode[] = slots.default()
|
|
return vNodes.some((vNode) => {
|
|
const tag = (vNode.type as Component).name
|
|
return tag === 'ElHeader' || tag === 'ElFooter'
|
|
})
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
return {
|
|
isVertical,
|
|
}
|
|
},
|
|
})
|
|
</script>
|