Skip to content

usePreferredDark

类别
导出体积
1.21 kB
上次更改
2 months ago
相关

响应式的深色主题偏好。

示例

喜欢深色:
false

用法

ts
import { 
usePreferredDark
} from '@vueuse/core'
const
isDark
=
usePreferredDark
()

组件使用

vue
<template>
  <UsePreferredDark v-slot="{ 
prefersDark
}">
首选深色主题: {{
prefersDark
}}
</UsePreferredDark> </template>

类型声明

ts
/**
 * 响应式深色主题偏好。
 *
 * @see https://vueuse.org/usePreferredDark
 * @param [options]
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function 
usePreferredDark
(
options
?:
ConfigurableWindow
,
):
ComputedRef
<boolean>

源码

源码演示文档

贡献者

Anthony Fu
一纸忘忧
SerKo
IlyaL
Anthony Fu
vaakian X
wheat
Alex Kozack
Antério Vieira

更新日志

8c521 - feat(components)!: refactor components and make them consistent (#4912)
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)