<DevOnly>
使用 <DevOnly> 组件仅在开发期间渲染组件。
Nuxt 提供了 <DevOnly>
组件,用于仅在开发期间渲染组件。
生产环境构建中将不包含该内容。
pages/example.vue
<template>
<div>
<Sidebar />
<DevOnly>
<!-- this component will only be rendered during development -->
<LazyDebugBar />
<!-- if you ever require to have a replacement during production -->
<!-- be sure to test these using `nuxt preview` -->
<template #fallback>
<div><!-- empty div for flex.justify-between --></div>
</template>
</DevOnly>
</div>
</template>
插槽
#fallback
:如果您需要在生产环境中使用替换内容。
<template>
<div>
<Sidebar />
<DevOnly>
<!-- this component will only be rendered during development -->
<LazyDebugBar />
<!-- be sure to test these using `nuxt preview` -->
<template #fallback>
<div><!-- empty div for flex.justify-between --></div>
</template>
</DevOnly>
</div>
</template>