Teleport
<Teleport> 的 to 目标需要一个 CSS 选择器字符串或一个实际的 DOM 节点。
Nuxt 目前仅支持传送到body的 SSR,客户端支持使用<ClientOnly>包装器的其他目标。
传送到body示例
vue
<template>
<button @click="open = true">
Open Modal
</button>
<Teleport to="body">
<div v-if="open" class="modal">
<p>Hello from the modal!</p>
<button @click="open = false">
Close
</button>
</div>
</Teleport>
</template>
客户端传送示例
vue
<template>
<ClientOnly>
<Teleport to="#some-selector">
<!-- content -->
</Teleport>
</ClientOnly>
</template>