如何做才能使 render(vnode,**) 拥有和 <component :is="vnode" /> 相同的上下文?
<script lang="ts" setup>
import { h, render } from "vue";
const vnode = h("div");
requestAnimationFrame(() => {
render(vnode, document.querySelector(".content-floating-box")!);
});
</script>
<template>
<div class="content-floating-box"></div>
</template>
<script lang="ts" setup>
import { h } from "vue";
const vnode = h("div");
</script>
<template>
<div class="content-floating-box">
<component :is="vnode" />
</div>
</template>
在位于 <app /> 内使用 render 插入 vnode 时会提示 injection "n-config-provider" not found.
<template>
<!-- https://www.naiveui.com/zh-CN/light/docs/customize-theme -->
<n-config-provider>
<app />
</n-config-provider>
</template>
无效尝试:
vue3官方没提供,只能手动继承父级的appContext和provides
https://github.com/orgs/vuejs/discussions/11213