Skip to content

usePointerLock

类别
导出体积
1.44 kB
上次更改
6 minutes ago

响应式的指针锁定

示例

基本用法

ts
import { 
usePointerLock
} from '@vueuse/core'
const {
isSupported
,
lock
,
unlock
,
element
,
triggerElement
} =
usePointerLock
()

组件用法

vue
<template>
  <UsePointerLock v-slot="{ 
lock
}">
<
canvas
/>
<
button
@
click
="
lock
">
在画布上锁定指针 </
button
>
</UsePointerLock> </template>

类型声明

ts
export interface UsePointerLockOptions extends ConfigurableDocument {}
export interface UsePointerLockReturn extends Supportable {
  
element
:
ShallowRef
<
MaybeElement
>
triggerElement
:
ShallowRef
<
MaybeElement
>
lock
: (
e
:
MaybeElementRef
| Event) =>
Promise
<
MaybeElement
>
unlock
: () =>
Promise
<boolean>
} /** * 响应式指针锁 * * @see https://vueuse.org/usePointerLock * @param target * @param options * * @__NO_SIDE_EFFECTS__ */ export declare function
usePointerLock
(
target
?:
MaybeElementRef
,
options
?: UsePointerLockOptions,
): UsePointerLockReturn

源码

源码演示文档

贡献者

一纸忘忧

更新日志

没有最近的更新日志