You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vite-vue3-lowcode/preview/views/slot-item.vue

62 lines
1.6 KiB

<!--
* @Author: 卜启缘
* @Date: 2021-06-12 22:18:48
* @LastEditTime: 2021-06-25 08:48:07
* @LastEditors: 卜启缘
* @Description:
* @FilePath: \vite-vue3-lowcode\preview\views\slot-item.vue
-->
4 years ago
<template>
<div class="__slot-item">
4 years ago
<comp-render :element="element" :config="config">
<template v-for="(value, key) in element.props?.slots" :key="key" #[key]>
<template v-for="item in value?.children" :key="item._vid">
<slot-item :element="item" :config="config" />
</template>
</template>
</comp-render>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, PropType } from 'vue'
4 years ago
import CompRender from './comp-render'
import { useAnimate } from '@/hooks/useAnimate'
import type { VisualEditorBlockData } from '@/visual-editor/visual-editor.utils'
4 years ago
export default defineComponent({
4 years ago
name: 'SlotItem',
components: { CompRender },
props: {
element: {
type: [Object] as PropType<VisualEditorBlockData>,
4 years ago
default: () => ({})
},
config: {
type: Object,
default: () => ({})
}
},
setup(props) {
onMounted(() => {
const animations = props.element.animations
if (animations?.length) {
let animateEl =
(window.$$refs[props.element._vid]?.$el as HTMLElement) ??
(window.$$refs[props.element._vid] as HTMLElement)
animateEl = animateEl?.closest('.__slot-item')?.firstChild as HTMLElement
if (animateEl) {
useAnimate(animateEl, animations)
}
}
})
return {}
4 years ago
}
})
4 years ago
</script>
<style scoped></style>