File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 11<script lang="ts" setup>
22import type { GlobalConfigProvider } from ' tdesign-vue-next' ;
33
4- import { onMounted } from ' vue' ;
4+ import { watch } from ' vue' ;
55
66import { usePreferences } from ' @vben/preferences' ;
77
@@ -12,12 +12,13 @@ import zhConfig from 'tdesign-vue-next/es/locale/zh_CN';
1212defineOptions ({ name: ' App' });
1313const { isDark } = usePreferences ();
1414
15- onMounted (() => {
16- document .documentElement .setAttribute (
17- ' theme-mode' ,
18- isDark .value ? ' dark' : ' ' ,
19- );
20- });
15+ watch (
16+ () => isDark .value ,
17+ (dark ) => {
18+ document .documentElement .setAttribute (' theme-mode' , dark ? ' dark' : ' ' );
19+ },
20+ { immediate: true },
21+ );
2122
2223const customConfig: GlobalConfigProvider = {
2324 // 可以在此处定义更多自定义配置,具体可配置内容参看 API 文档
Original file line number Diff line number Diff line change @@ -38,15 +38,15 @@ function notify(type: NotificationType) {
3838 description =" 支持多语言,主题功能集成切换等"
3939 title =" TDesign Vue组件使用演示"
4040 >
41- <Card class =" mb-5" title =" 按钮" >
41+ <Card class =" ! mb-5" title =" 按钮" >
4242 <Space >
4343 <Button >Default</Button >
4444 <Button theme =" primary" > Primary </Button >
4545 <Button theme =" default" > Info </Button >
4646 <Button theme =" danger" > Error </Button >
4747 </Space >
4848 </Card >
49- <Card class =" mb-5" title =" Message" >
49+ <Card class =" ! mb-5" title =" Message" >
5050 <Space >
5151 <Button @click =" info" > 信息 </Button >
5252 <Button theme =" danger" @click =" error" > 错误 </Button >
@@ -55,7 +55,7 @@ function notify(type: NotificationType) {
5555 </Space >
5656 </Card >
5757
58- <Card class =" mb-5" title =" Notification" >
58+ <Card class =" ! mb-5" title =" Notification" >
5959 <Space >
6060 <Button @click =" notify('info')" > 信息 </Button >
6161 <Button theme =" danger" @click =" notify('error')" > 错误 </Button >
You can’t perform that action at this time.
0 commit comments