代码
- 父组件
<template>
<div class="component-name">
<!-- 全局自动的icon -->
<Extend :render="render" />
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, onMounted, nextTick } from 'vue';
import Extend from './components/extend';
const render = () => {
return h('div', {}, 'sdflksjdfs');
};
</script>
<style lang="scss" scoped></style>
- extend.tsx
import { defineComponent, PropType } from 'vue';
export default defineComponent({
name: 'Extend',
props: {
render: {
type: Function as PropType<() => void>,
default: () => void 0
}
},
setup(props) {
return () => {
const { render } = props;
return render && render();
};
}
});
标签:函数,render,渲染,props,import,自定义
From: https://www.cnblogs.com/jocongmin/p/18335647