naive-ui/demo/documentation/components/config-consumer/enUS/basic.demo.md

32 lines
640 B
Markdown
Raw Normal View History

# Basic
2020-12-12 14:44:44 +08:00
2020-02-03 19:37:56 +08:00
Get current theme and namespace.
2020-12-12 14:44:44 +08:00
```html
<n-config-consumer
@theme-change="handleThemeChange"
@namespace-change="handleNamespaceChange"
>
2019-11-14 17:53:23 +08:00
<template v-slot="{ theme, namespace }">
<div>
<div>theme: {{ theme }}</div>
<div>namespace: {{ namespace }}</div>
</div>
</template>
</n-config-consumer>
```
2020-12-12 14:44:44 +08:00
```js
export default {
inject: ['message'],
methods: {
2020-12-12 15:33:41 +08:00
handleThemeChange (value, oldValue) {
this.message.info('Theme Change: `' + value + '` theme')
},
2020-12-12 15:33:41 +08:00
handleNamespaceChange (value, oldValue) {
this.message.info('Namespace Change: `' + value + '` namespace')
}
}
}
2020-12-12 14:44:44 +08:00
```