import useDarkmode 的求助 #4520
Answered
by
Mister-Hope
firstack-it
asked this question in
Q&A
-
1. import { useDarkmode } from 'vuepress-theme-hope/client'
2. import { useDarkmode } from '@theme-hope/modules/outlook/composables/index' 麻烦问下各位,我想在客户端监听用户切换 Uncaught SyntaxError: The requested module '/@fs/C:/Users/xxx/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_vuep_omsqo4pdvu25ooyehif6hq2fim/node_modules/vuepress-theme-hope/lib/client/index.js?v=3c3fe44a' does not provide an export named 'useDarkmode' 组件如下 <template></template>
<script setup lang="ts">
// import { useDarkmode } from '@theme-hope/modules/outlook/composables/index'
import { useDarkmode } from 'vuepress-theme-hope/client'
import { onBeforeMount, watch } from 'vue'
import { defineWatermarkConfig } from '@vuepress/plugin-watermark/client'
const { isDarkmode } = useDarkmode()
watch(isDarkmode, (newValue, oldValue) => {
changeDarkMode(newValue)
})
onBeforeMount(() => {
changeDarkMode(isDarkmode.value)
})
const changeDarkMode = (isDarkmode: any) => {
document.getElementsByTagName('html')[0].className = isDarkmode ? 'dark' : ''
// defineWatermarkConfig({ fontColor: isDarkmode ? '#fff' : '#000' })
defineWatermarkConfig({ fontColor: isDarkmode ? '#e03e2d' : '#3598db' })
}
</script> |
Beta Was this translation helpful? Give feedback.
Answered by
Mister-Hope
Oct 15, 2024
Replies: 1 comment
-
如果你已经开启了custom: true 那么你应该通过别名方式。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
firstack-it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如果你已经开启了custom: true 那么你应该通过别名方式。