naive-ui/demo/documentation/components/configProvider/zhCN/transparent.md

34 lines
739 B
Markdown
Raw Normal View History

2020-02-03 19:28:16 +08:00
# 无包裹 DOM
如果不需要包裹 DOM设置 `transparent`。(注意,这种情况下只接受一个子节点)
2020-01-04 17:32:23 +08:00
```html
2020-02-03 19:28:16 +08:00
<div>
<n-button @click="theme = 'dark'">深色主题</n-button>
<n-button @click="theme = 'light'">浅色主题</n-button>
</div>
2020-01-04 17:32:23 +08:00
<n-config-provider :theme="theme" :theme-environment="env" transparent>
<n-config-consumer>
<template v-slot="{ themeEnvironment }">
2020-02-03 19:28:16 +08:00
<n-tag>无包裹 DOM{{ themeEnvironment }}</n-tag>
2020-01-04 17:32:23 +08:00
</template>
</n-config-consumer>
</n-config-provider>
```
```js
export default {
data () {
return {
theme: 'light',
env: {
2020-02-03 19:28:16 +08:00
dark: '氯化钠',
light: '离子化合物'
2020-01-04 17:32:23 +08:00
}
}
}
}
```
2020-02-03 19:28:16 +08:00
```css
.n-button {
margin: 0 8px 12px 0;
}
```