mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-27 05:00:48 +08:00
746 B
746 B
不需要包裹 DOM
如果不需要包裹 DOM,设置 abstract
。(注意,这种情况下只接受一个子节点)
<n-space vertical>
<n-space>
<n-button @click="theme = 'dark'">深色主题</n-button>
<n-button @click="theme = 'light'">浅色主题</n-button>
</n-space>
<n-config-provider :theme="theme" :theme-environments="env" abstract>
<n-config-consumer v-slot="{ themeEnvironment }">
<n-card>
<n-tag>无包裹 DOM:{{ themeEnvironment }}</n-tag>
</n-card>
</n-config-consumer>
</n-config-provider>
</n-space>
export default {
data () {
return {
theme: 'dark',
env: {
dark: '氯化钠',
light: '离子化合物'
}
}
}
}