Skip to content

useOnline

类别
导出体积
979 B
上次更改
2 months ago

响应式的在线状态。是 useNetwork 的封装。

示例

请断开网络查看更改
状态:Online

使用方法

ts
import { 
useOnline
} from '@vueuse/core'
const
online
=
useOnline
()

组件使用

vue
<template>
  <UseOnline v-slot="{ 
isOnline
}">
是否在线: {{
isOnline
}}
</UseOnline> </template>

类型声明

ts
/**
 * 响应式在线状态。
 *
 * @see https://vueuse.org/useOnline
 * @param options
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function 
useOnline
(
options
?:
ConfigurableWindow
,
):
Readonly
<
ShallowRef
<boolean>>

源码

源码演示文档

贡献者

Anthony Fu
一纸忘忧
SerKo
IlyaL
Anthony Fu
vaakian X
Mike Jules
wheat
Alex Kozack
Antério Vieira

更新日志

8c521 - feat(components)!: refactor components and make them consistent (#4912)
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)