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

494 B

提供主题

使用 n-config-provider 来设定它全部的后代组件主题。

<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>
import { ref } from 'vue'
import { darkTheme } from 'naive-ui'

export default {
  setup () {
    return {
      darkTheme,
      theme: ref(null)
    }
  }
}