
简体中文
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | x | x | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
callback | (result: OnNetworkStatusChangeCallbackResult) => void | 是 | - | - | - |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
isConnected | boolean | 是 | - | 当前是否有网络连接 | |
networkType | string | 是 | - | 网络类型 |
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.0 | 4.41 | x | x | 4.61 |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
callback | (result: any) => void | 是 | - | - | - |
Template
Script
<template>
<page-head title="networkStatusChange"></page-head>
<view class="uni-list-cell-padding status-box">
<text class="uni-title-text">网络状态</text>
<view class="uni-row uni-common-mt">
<text class="uni-hello-text">是否连接:</text>
<text>{{ isConnected ? '已连接' : '未连接' }}</text>
</view>
<view class="uni-row uni-common-mt">
<text class="uni-hello-text">网络类型:</text>
<text>{{ networkType }}</text>
</view>
<view class="uni-row uni-common-mt">
<text class="uni-hello-text">监听状态:</text>
<text>{{ listenStatus }}</text>
</view>
</view>
<view class="uni-list-cell-padding uni-common-mt">
<button type="primary" @click="startListen">开始监听</button>
<button type="default" class="uni-common-mt" @click="stopListen">停止监听</button>
</view>
</template>
<style>
.status-box {
background-color: #FFFFFF;
margin: 0 20px;
}
</style>
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |