mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-09 04:31:35 +08:00
doc(config-consumer)
This commit is contained in:
parent
ca555f31fe
commit
bbfcb2da8d
@ -1,9 +1,11 @@
|
||||
# Style Scheme
|
||||
|
||||
Style scheme exposes the style variables used inside naive-ui. You can use it to create same styled components of naive-ui.
|
||||
```html
|
||||
<n-config-consumer>
|
||||
<template v-slot="{ styleScheme }">
|
||||
<n-code :code="JSON.stringify(styleScheme, 0, 2)" language="js"></n-code>
|
||||
</template>
|
||||
</n-config-consumer>
|
||||
<div style="overflow: auto">
|
||||
<n-config-consumer>
|
||||
<template v-slot="{ styleScheme }">
|
||||
<n-code :code="JSON.stringify(styleScheme, 0, 2)" language="js"></n-code>
|
||||
</template>
|
||||
</n-config-consumer>
|
||||
</div>
|
||||
```
|
@ -5,4 +5,17 @@ Config Consumer is built for getting config (usually as global config) of Config
|
||||
basic
|
||||
theme-environment
|
||||
color
|
||||
```
|
||||
```
|
||||
## Props
|
||||
|
||||
## Events
|
||||
|Name|Parameters|
|
||||
|-|-|
|
||||
|theme-change|(theme, oldTheme)|
|
||||
|namespace-change|(namespace, oldNamespace)|
|
||||
|language-change|(language, oldLanguage)|
|
||||
|
||||
## Slots
|
||||
|Name|Parameters|
|
||||
|-|-|
|
||||
|default|({ theme, namespace, language, themeEnvironment, styleScheme })|
|
@ -2,13 +2,15 @@
|
||||
```html
|
||||
<n-button @click="theme = 'dark'">Dark Theme</n-button>
|
||||
<n-button @click="theme = 'light'">Light Theme</n-button>
|
||||
<n-config-provider :theme="theme" :theme-environment="env">
|
||||
<n-config-consumer>
|
||||
<template v-slot="{ themeEnvironment }">
|
||||
{{ themeEnvironment }}
|
||||
</template>
|
||||
</n-config-consumer>
|
||||
</n-config-provider>
|
||||
<div>
|
||||
<n-config-provider :theme="theme" :theme-environment="env">
|
||||
<n-config-consumer>
|
||||
<template v-slot="{ themeEnvironment }">
|
||||
{{ themeEnvironment }}
|
||||
</template>
|
||||
</n-config-consumer>
|
||||
</n-config-provider>
|
||||
</div>
|
||||
```
|
||||
```js
|
||||
export default {
|
||||
|
@ -15,6 +15,9 @@ export default {
|
||||
},
|
||||
synthesizedThemeEnvironment: function (value, oldValue) {
|
||||
this.$emit('theme-environment-change', value, oldValue)
|
||||
},
|
||||
'NConfigProvider.inheritedLanguage': function (value, oldValue) {
|
||||
this.$emit('language-change', value, oldValue)
|
||||
}
|
||||
},
|
||||
render (h) {
|
||||
|
Loading…
Reference in New Issue
Block a user