Skip to content

usePreferredContrast

反应式 prefers-contrast 媒体查询。

¥Reactive prefers-contrast media query.

示例

Preferred contrast:
no-preference

用法

¥Usage

js
import { usePreferredContrast } from '@vueuse/core'

const preferredContrast = usePreferredContrast()

组件用法

¥Component Usage

vue
<template>
  <UsePreferredContrast v-slot="{ contrast }">
    Preferred Contrast: {{ contrast }}
  </UsePreferredContrast>
</template>

类型声明

typescript
export type ContrastType = "more" | "less" | "custom" | "no-preference"
/**
 * Reactive prefers-contrast media query.
 *
 * @see https://vueuse.org/usePreferredContrast
 * @param [options]
 */
export declare function usePreferredContrast(
  options?: ConfigurableWindow,
): ComputedRef<ContrastType>

源代码

源代码示例文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号