Skip to content
On this page

Functions

Core
Add-ons
Sort by
Filters

State

createGlobalState-将状态保存全局作用域中,以便跨Vue实例复用。
createInjectionState-创建可以注入到组件中的全局状态。
createSharedComposable-让一个钩子函数可用于多个Vue实例中。
useAsyncState-响应式获取异步状态。不会阻塞setup 函数,在promise完成后,将自动触发。
useDebouncedRefHistory-useRefHistory 的简写,带有防抖过滤器。
useLastChanged-记录最后一次更改的时间戳
useManualRefHistory-调用 commit() 时,手动跟踪ref的更改历史,提供撤消和重做功能
useRefHistory-跟踪 ref 的更改历史,提供撤消和重做功能
useStorageAsync-支持异步的响应式Storage
useThrottledRefHistory-带节流过滤器的 useRefHistory 的简写。

Elements

useActiveElement-响应式 document.activeElement
useDraggable-使元素可拖拽。
useDropZone-创建一个可以放置文件的区域。
useElementBounding-让HTML元素的bounding box 响应式
useElementSize-元素尺寸大小响应式
useElementVisibility-跟踪元素在视口中的可见性。
useIntersectionObserver-响应式监听目标元素的可见性。
useMouseInElement-响应式获取鼠标相对于元素的位置
useResizeObserver-监听元素内容和边框尺寸的变化。
useWindowFocus-使用 window.onfocuswindow.onblur 事件响应式跟踪窗口焦点。
useWindowScroll-响应式获取窗口的滚动位置。
useWindowSize-响应式获取窗口尺寸

Browser

useBluetooth-响应式 Web Bluetooth API。提供连接低功耗蓝牙外设并与之交互的能力。
useBreakpoints-响应式获取视口断点
useBrowserLocation-响应式获取 Location
useClipboard-响应式 Clipboard API。剪贴板 API 提供了响应剪贴板命令(剪切、复制和粘贴)与异步读写系统剪贴板的能力。从权限 Permissions API。获取权限之后,才能访问剪贴板内容;如果用户没有授予权限,则不允许读取或更改剪贴板内容。
useColorMode-具有自动数据持久化的响应式颜色模式(深色/浅色/自定义)。
useCssVar-操作css变量
useDark-具有自动数据持久性的响应式暗黑模式。
useEventListener-轻松使用事件监听。在挂载时使用 addEventListener 注册,在卸载时自动使用 removeEventListener
useFavicon-响应式 favicon
useFileDialog-轻松打开文件对话框。
useFileSystemAccess-创建和读写本地文件FileSystemAccessAPI
useFullscreen-响应式Fullscreen API。它添加了以全屏模式呈现特定元素(及其后代)的方法,并在不再需要时退出全屏模式。这使得可以使用用户的整个屏幕呈现所需的内容(例如在线游戏),从屏幕上隐藏所有的浏览器用户界面以及其他应用,直到关闭全屏模式。
useGamepad-provides reactive bindings for the Gamepad API
useImage-在浏览器中响应式加载图像,你可以等待结果显示或显示一个回退方案
useMediaControls-audiovideo 元素的响应式媒体控件。
useMediaQuery-响应式Media Query。创建 MediaQueryList 对象后,您可以查询结果或在结果更改时接收通知。
useMemory-响应式获取内存信息
useObjectUrl-响应式的用URL表示对象
usePermission-响应式 Permissions API。权限 API 提供的工具允许开发者在权限方面实现更好的用户体验。
usePreferredDark-响应式深色主题偏好
usePreferredLanguages-响应式 Navigator Languages。为web开发人员提供有关用户首选语言的信息。例如,这可能有助于根据用户的首选语言调整用户界面的语言,以提供更好的体验。
useScreenOrientation-响应式Screen Orientation API。它为web开发者提供有关用户当前屏幕方向的信息。
useScreenSafeArea-响应式 env(safe-area-inset-*)
useScriptTag-注入 script 标签
useShare-响应式 Web Share API。浏览器提供可以共享文本或文件内容的功能。
useStyleTag-head上注入响应式 style 元素
useTextareaAutosize-根据内容自动更新文本区域的高度。
useTextDirection-响应式操作元素文本 方向
useTitle-响应式document title
useWakeLock-响应式屏幕唤醒 API。提供了一种方法来防止设备在应用程序需要继续运行时调暗或锁定屏幕。
useWebWorker-简单的 Web Workers 注册和通信。
useWebWorkerFn-使用 Promise 语法,在不阻塞 UI 的情况下运行复杂功能,运行在 alewin/useWorker

Sensors

onClickOutside-监听元素外部的点击事件,对模态框和下拉菜单很有用。
onKeyStroke-监听键盘事件
onLongPress-监听一个元素的长按事件。
onStartTyping-当用户开始在不可编辑的元素上输入时触发。
useBattery-响应式 Battery Status API,更多时候被称之为 Battery API
useDeviceMotion-响应式 DeviceMotionEvent,为 web 开发者提供了关于设备的位置和方向的改变速度的信息。
useDeviceOrientation-响应式DeviceOrientationEvent。提供给网页开发者当设备在浏览页面时物理旋转的信息。
useDevicesList-列出可用的输入输出设备的响应式列表
useElementByPoint-以坐标点响应式操作元素。
useElementHover-响应元素的悬停状态
useFocus-响应式跟踪或设置 DOM 元素的焦点状态。状态变化以反映目标元素是否是焦点元素,从外部设置响应值为 truefalse,将分别触发 focusblur 事件。
useFocusWithin-用于跟踪元素或其后代之一是否获取了焦点的响应式工具。匹配 :focus-within 伪类的行为。一个常见的用例是在表单元素上查看整个表单是否获取了焦点。
useFps-响应式 FPS(每秒帧数)。
useGeolocation-响应式 Geolocation API。允许用户向 web 应用程序提供他们的位置。出于隐私考虑,报告地理位置前会先请求用户许可。
useIdle-跟踪用户是否处于非活动状态。
useInfiniteScroll-元素无限滚动。
useKeyModifier-响应式 键盘修饰键状态。跟踪任何修饰键的状态 - 请参阅浏览器兼容性说明。
useMagicKeys-响应式按下状态,支持组合键。
useMouse-响应式获取鼠标位置
useMousePressed-响应式鼠标按下状态。由目标元素的 mousedown touchstart 事件触发,并由window上的 mouseup mouseleave touchend touchcancel 事件释放。
useNetwork-响应式 Network status。网络状态 API 可以获取到系统的网络连接信息,比如说连接方式是 WiFi 还是蜂窝。应用程序可以根据此信息为用户展现不同清晰度的内容。该 API 是由 NetworkInformation 接口和 Navigator 接口上新增的一个 connection 属性组成的。
useOnline-响应式在线状态,useNetwork的包装器
usePageLeave-响应式获取鼠标是否离开页面。
useParallax-轻松创建视差效果。如果不支持旋转,它会使用 useDeviceOrientation 并回退到 useMouse
usePointerSwipe-基于PointerEvents的响应式滑动检测
useScroll-响应式获取滚动位置和状态。
useScrollLock-锁定元素的滚动。
useSwipe-基于 TouchEvents的响应式滑动检测
useTextSelection-基于 Window.getSelection 响应式跟踪用户文本选择

Network

useEventSource-使用EventSourceServer-Sent-Events 实例会对 HTTP 服务开启一个持久化的连接,以 text/event-stream 格式发送事件。
useFetch-响应式 Fetch API,提供中止请求、在请求被触发之前拦截请求、在 url 更改时自动重新获取请求以及使用预定义选项创建您自己的 useFetch

Animation

useInterval-每隔一段时间响应式增加计数
useIntervalFn-带控件的 setInterval 包装器
useNow-响应式获取当前 Date 实例。
useRafFn-在每个 requestAnimationFrame 上调用函数。可控制暂停和恢复。
useTimeout-在给定时间后更新值。
useTimeoutFn-带控件的 setTimeout 包装器。
useTimestamp-响应式获取当前时间戳
useTransition-值之间的过度

Component

computedInject-combine computed and inject
templateRef-将 ref 绑定到模板元素的简写。
tryOnBeforeMount-安全执行 onBeforeMount。如果在组件生命周期内就调用 onBeforeMount(),如果不在就调用函数
tryOnBeforeUnmount-安全执行 onBeforeUnmount。如果在组件生命周期内,则调用 onBeforeUnmount(),如果不在,则什么都不做
tryOnMounted-安全执行 onMounted。如果在组件生命周期内,则调用 onMounted(),如果不在,则调用该函数
tryOnScopeDispose-安全执行 onScopeDispose。如果它在effect作用域生命周期内,则调用 onScopeDispose(),如果不在,则什么都不做
tryOnUnmounted-安全执行 onUnmounted。如果在组件生命周期内,则调用 onUnmounted(),如果不在,则什么都不做
unrefElement-取消对 dom 元素的引用。
useCurrentElement-获取当前组件的元素作为 ref。
useMounted-使用ref记录挂载状态
useTemplateRefsList-将 refs 绑定到 v-for 中的模板元素和组件的简写。
useVirtualList-轻松创建虚拟列表。虚拟列表(有时称为virtual scrollers)允许您高效地呈现大量的项。通过使用 wrapper 元素来模拟容器的完整高度,只呈现最少数量的DOM节点来显示 container 元素中的项。
useVModel-v-model 简写,props + emit -> ref
useVModels-props v-model 简写。可以把它想象成 toRefs(props),但变化也会触发更新。

Watch

until-监听一次Promise后的变化
watchArray-监听数组的添加和删除
watchAtMost-指定 watch 触发的次数。
watchDebounced-防抖 watch
watchIgnorable-可忽略的 watch
watchOnce-watch 只触发一次。
watchPausable-可暂停的 watch
watchThrottled-节流 watch
watchTriggerable-可以手动触发的 watch
watchWithFilter-带事件过滤器的 watch 控件
whenever-监听真值的简写

Reactivity

computedAsync-computed for async functions
computedEager-eager computed without lazy evaluation
computedWithControl-explicitly define the dependencies of computed
extendRef-add extra attributes to Ref
reactify-converts plain functions into reactive functions
reactifyObject-apply reactify to an object
reactiveComputed-computed reactive object
reactiveOmit-reactively omit fields from a reactive object
reactivePick-reactively pick fields from a reactive object
refAutoReset-a ref which will be reset to the default value after some time
refDebounced-debounce execution of a ref value
refDefault-apply default value to a ref
refThrottled-throttle changing of a ref value
refWithControl-fine-grained controls over ref and its reactivity
resolveRef-normalize value/ref/getter to ref or computed
resolveUnref-get the value of value/ref/getter
syncRef-two-way refs synchronization
syncRefs-keep target refs in sync with a source ref
toReactive-converts ref to reactive
toRefs-extended toRefs that also accepts refs of an object

Array

useArrayEvery-响应式 Array.every
useArrayFilter-reactive Array.filter
useArrayFind-reactive Array.find
useArrayFindIndex-reactive Array.findIndex
useArrayFindLast-reactive Array.findLast
useArrayJoin-reactive Array.join
useArrayMap-reactive Array.map
useArrayReduce-reactive Array.reduce
useArraySome-reactive Array.some
useArrayUnique-reactive unique array
useSorted-reactive sort array

Time

useDateFormat-get the formatted date according to the string of tokens passed in
useTimeAgo-reactive time ago

Utilities

createEventHook-utility for creating event hooks
createUnrefFn-make a plain function accepting ref and raw values as arguments
get-shorthand for accessing ref.value
isDefined-non-nullish checking type guard for Ref
makeDestructurable-make isomorphic destructurable for object and array at the same time
set-shorthand for ref.value = x
useAsyncQueue-executes each asynchronous task sequentially and passes the current task result to the next task
useBase64-reactive base64 transforming
useCached-cache a ref with a custom comparator
useCloned-reactive clone of a ref
useConfirmDialog-creates event hooks to support modals and confirmation dialog chains
useCounter-basic counter with utility functions
useCycleList-cycle through a list of items
useDebounceFn-debounce execution of a function
useEventBus-a basic event bus
useMemoize-cache results of functions depending on arguments and keep it reactive
useOffsetPagination-reactive offset pagination
usePrevious-holds the previous value of a ref
useStepper-provides helpers for building a multi-step wizard interface
useSupported-sSR compatibility isSupported
useThrottleFn-throttle execution of a function
useTimeoutPoll-use timeout to poll something
useToggle-a boolean switcher with utility functions
useToNumber-reactively convert a string ref to number
useToString-reactively convert a ref to string

@Electron

useIpcRenderer-provides ipcRenderer and all of its APIs
useIpcRendererOn-use ipcRenderer.on with ease and ipcRenderer.removeListener automatically on unmounted
useZoomFactor-reactive WebFrame zoom factor
useZoomLevel-reactive WebFrame zoom level

@Firebase

useAuth-reactive Firebase Auth binding
useFirestore-reactive Firestore binding

@Head

createHead-create the head manager instance.
useHead-update head meta tags reactively.

@Integrations

useAxios-wrapper for axios
useChangeCase-reactive wrapper for change-case
useDrauu-reactive instance for drauu
useFocusTrap-reactive wrapper for focus-trap
useFuse-easily implement fuzzy search using a composable with Fuse.js
useJwt-wrapper for jwt-decode
useNProgress-reactive wrapper for nprogress
useQRCode-wrapper for qrcode

@Math

createGenericProjection-generic version of createProjection
createProjection-reactive numeric projection from one domain to another
logicAnd-AND condition for refs
logicNot-NOT condition for ref
logicOr-OR conditions for refs
useAbs-reactive Math.abs
useAverage-get the average of an array reactively
useCeil-reactive Math.ceil
useClamp-reactively clamp a value between two other values
useFloor-reactive Math.floor
useMath-reactive Math methods
useMax-reactive Math.max
useMin-reactive Math.min
usePrecision-reactively set the precision of a number
useProjection-reactive numeric projection from one domain to another
useRound-reactive Math.round
useSum-get the sum of an array reactively
useToFixed-reactive toFixed
useTrunc-reactive Math.trunc

@Motion

useElementStyle-sync a reactive object to a target element CSS styling
useElementTransform-sync a reactive object to a target element CSS transform.
useMotion-putting your components in motion.
useMotionProperties-access Motion Properties for a target element.
useMotionVariants-handle the Variants state and selection.
useSpring-spring animations.

@Router

useRouteHash-shorthand for a reactive route.hash
useRouteParams-shorthand for a reactive route.params
useRouteQuery-shorthand for a reactive route.query

@RxJS

from-/ fromEvent
toObserver-sugar function to convert a ref into an RxJS Observer
useSubject-bind an RxJS Subject to a ref and propagate value changes both ways
useSubscription-use an RxJS Subscription without worrying about unsubscribing from it or creating memory leaks

@SchemaOrg

createSchemaOrg-create the schema.org manager instance.
useSchemaOrg-update schema.org reactively.

@Sound

useSound-play sound effects reactively.

Released under the MIT License.