-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
动态修改主题darkTheme/null无法反应到所有组件 #6612
Labels
untriaged
need to sort
Comments
App.vue <template>
<n-loading-bar-provider>
<n-message-provider>
<n-notification-provider>
<n-modal-provider>
<n-dialog-provider>
<n-config-provider :theme="theme">
<!-- <n-global-style /> --> <!--验证问题暂时不用-->
<n-layout>
<!-- <NGlobalStyle></NGlobalStyle> -->
<n-card size="small">
<n-space>
<n-switch
v-model:value="switchTheme"
:value="null"
size="large"
>
<template #checked
>开启亮色</template
>
<template #unchecked>
开启暗色
</template>
</n-switch>
</n-space>
</n-card>
</n-layout>
<!---->
<Demo />
<n-space vertical>
<div>
<n-space>
<n-input placeholder="请输入内容1" />
<n-input placeholder="请输入内容2" />
<n-input placeholder="请输入内容3" />
</n-space>
</div>
<n-layout
><n-space>
<n-input placeholder="请输入内容1" />
<n-input placeholder="请输入内容2" />
<n-input placeholder="请输入内容3"
/></n-space>
</n-layout>
</n-space>
<!-- -->
</n-config-provider>
</n-dialog-provider>
</n-modal-provider>
</n-notification-provider>
</n-message-provider>
</n-loading-bar-provider>
</template>
<script>
import { defineComponent } from "vue"
import { darkTheme } from "naive-ui"
import { ref } from "vue"
import Demo from "./components/Demo.vue"
// import Group from "./components/Group.vue"
export default defineComponent({
components: {
Demo,
// Group,
},
setup() {
return {
darkTheme,
theme: ref(null),
switchTheme: ref(false),
}
},
watch: {
switchTheme(newValue) {
this.theme = newValue ? darkTheme : null
console.log(
`newValue: ${newValue} 模式切换为: ${
newValue ? "暗色" : "亮色"
}`
)
},
},
})
</script> |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
子组件必须在
n-layout
中,子组件才能被正确的渲染主题,否则组件就默认不可见,这点在默认主题下
是没有问题的我查询了官方文档,没有此类描述 (
默认主题下
是指初始化被设置了darkTheme
或者 是未设置)官网所述: 只需要组件包含在
n-config-provider
中即可同步主题样式代码片段均来源于官网,第一次使用
默认色
切换后(输入框看到,必须得输入了才会显示元素(这里是n-input))
Steps to reproduce
直接贴上我所陈诉的BUG相关的代码 (
Group
组件的内容是复制的官网中的一个 表单组件 的代码)n-global-style
最终也能实现,但是和议题论点应该不匹配Link to minimal reproduction
https://codesandbox.io/p/sandbox/quan-ju-hua-pei-zhi-config-provider-js-zgrzlk
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: