琢磨了半天,其实非常简单

自定义组件: VNode

可以独立创建一共 VNode.ts 或者 js 文件, 总之就是导出一个Vue组件,你也可以直接在组件里面定义这个对象,然后直接在 template 中使用即可

export const VNode = defineComponent({
    props: {
        content:{
            type:Object
        }
    },
    render(): any {
        return this.content;
    }
});

使用

sfc

<template>
	<VNode :content="h('a',{href:'https://baidu.com'},"百度一下" />
</template>
<script setup lang="ts">
import {h} from "vue";
import VNode from "xxxxx/VNode.ts";
</script>
Logo

前往低代码交流专区

更多推荐