usePreferredReducedMotion
响应式 prefers-reduced-motion 媒体查询。
演示
用法
js
import { usePreferredReducedMotion } from '@vueuse/core'
const preferredMotion = usePreferredReducedMotion()
组件用法
此函数还通过
@vueuse/components
包提供了一个无渲染组件版本。 了解更多关于用法的信息。
vue
<template>
<UsePreferredReducedMotion v-slot="{ motion }">
Preferred Reduced Motion: {{ motion }}
</UsePreferredReducedMotion>
</template>
类型声明
typescript
export type ReducedMotionType = "reduce" | "no-preference"
/**
* Reactive prefers-reduced-motion media query.
*
* @see https://vueuse.org.cn/usePreferredReducedMotion
* @param [options]
*/
export declare function usePreferredReducedMotion(
options?: ConfigurableWindow,
): ComputedRef<ReducedMotionType>
源代码
贡献者
更新日志
v12.0.0-beta.1
于 2024/11/21