Skip to content

network

NPM version

Platform Support

Platform Support

Platform Support

Platform Support

介绍:

网络状态插件

Reference

Method

  • onLine

    查看网络是否在线

ts
import { 
networkPlugin
} from "@plaoc/plugins";
await
networkPlugin
.
onLine
();
  • getStatus

    获取网络状态

ts
import { 
networkPlugin
} from "@plaoc/plugins";
await
networkPlugin
.
getStatus
();

Usage Plugins

vue
<script setup lang="ts">
import { 
networkPlugin
} from "@plaoc/plugins";
async function
getNetworkState
() {
const
state
=
networkPlugin
.
onLine
();
const
status
=
networkPlugin
.
getStatus
();
} </script>

Usage WebComponent

vue
<script setup lang="ts">
import { 
ref
,
onMounted
} from "vue";
import {
HTMLDwebNetworkElement
} from "@plaoc/plugins";
let
$networkPlugin
=
ref
<
HTMLDwebNetworkElement
>();
let
network
:
HTMLDwebNetworkElement
;
onMounted
(() => {
network
=
$networkPlugin
.
value
!;
}) async function
getNetworkState
() {
const
state
=
network
.
onLine
();
const
status
=
network
.
getStatus
();
} </script> <template> <
dweb-network
ref
="
$networkPlugin
"></
dweb-network
>
</template>

基于 MIT 许可发布