NodeRender.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <!-- 在下方添加自定义组件 -->
  3. <!-- 业务代码开始 -->
  4. <template v-if="node.type === 'test'">
  5. <text>这是一个测试节点</text>
  6. </template>
  7. <!-- 业务代码结束 -->
  8. <template v-else>
  9. <slot :node="node" :context="xContext" />
  10. <!-- #ifdef MP -->
  11. <!-- <text style="color: red;">自定义渲染插槽在MP环境下不支持,当前节点类型:{{props.node.type}}</text> -->
  12. <!-- #endif -->
  13. <!-- #ifndef MP -->
  14. <!-- <slot :node="node" :context="xContext" /> -->
  15. <!-- #endif -->
  16. </template>
  17. </template>
  18. <script setup lang="ts">
  19. import { inject, ref, type PropType } from 'vue';
  20. import type { DynamicXNode, DynamicXNodeContext } from '@/components/dynamic/DynamicX';
  21. const props = defineProps({
  22. node: {
  23. type: Object as PropType<DynamicXNode>,
  24. default: () => ({})
  25. },
  26. mergedProps: {
  27. type: Object as PropType<Record<string, any>>,
  28. default: () => ({})
  29. },
  30. });
  31. const emit = defineEmits([]);
  32. const xContext = inject<DynamicXNodeContext>('xContext');
  33. defineOptions({
  34. options: {
  35. virtualHost: true,
  36. }
  37. })
  38. </script>