naive-ui/demo/pages/docs/theme/zhCN/provide-theme.demo.md
2021-02-14 14:52:14 +08:00

29 lines
494 B
Markdown

# 提供主题
使用 `n-config-provider` 来设定它全部的后代组件主题。
```html
<n-config-provider :theme="theme">
<n-card>
<n-space>
<n-button @click="theme = darkTheme">深色</n-button>
<n-button @click="theme = null">浅色</n-button>
</n-space>
</n-card>
</n-config-provider>
```
```js
import { ref } from 'vue'
import { darkTheme } from 'naive-ui'
export default {
setup () {
return {
darkTheme,
theme: ref(null)
}
}
}
```