Skip to content

useElementByPoint

Category
Export Size
834 B
Last Changed
3 hours ago

根据点获取响应式元素。

Demo

用法

ts
import { useElementByPoint, useMouse } from '@vueuse/core'

const { x, y } = useMouse({ type: 'client' })
const { element } = useElementByPoint({ x, y })

Type Declarations

typescript
export interface UseElementByPointOptions<Multiple extends boolean = false>
  extends ConfigurableDocument {
  x: MaybeRefOrGetter<number>
  y: MaybeRefOrGetter<number>
  multiple?: MaybeRefOrGetter<Multiple>
  immediate?: boolean
  interval?: "requestAnimationFrame" | number
}
export interface UseElementByPointReturn<Multiple extends boolean = false>
  extends Pausable {
  isSupported: ComputedRef<boolean>
  element: ShallowRef<
    Multiple extends true ? HTMLElement[] : HTMLElement | null
  >
}
/**
 * Reactive element by point.
 *
 * @see https://vueuse.org/useElementByPoint
 * @param options - UseElementByPointOptions
 */
export declare function useElementByPoint<M extends boolean = false>(
  options: UseElementByPointOptions<M>,
): UseElementByPointReturn<M>

Source

SourceDemoDocs

Contributors

jorshen

Changelog

No recent changes

Released under the MIT License.