Back to Uni App

Wifi

docs/api/wifi.md

2.3.334.4 KB
Original Source

uni.startWifi(option) @startwifi

初始化Wi-Fi模块

本 API 是 uni ext api,需下载插件:uni-wifi

startWifi 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionWifiOption-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

option 的属性描述

名称类型必备默认值兼容性描述
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.stopWifi(option) @stopwifi

关闭 Wi-Fi 模块

本 API 是 uni ext api,需下载插件:uni-wifi

stopWifi 兼容性

Web微信小程序AndroidiOSHarmonyOS
--<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>4.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionWifiOption-Web: -; 微信小程序: -; Android: x; iOS: -; HarmonyOS: x

option 的属性描述

名称类型必备默认值兼容性描述
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.connectWifi(option) @connectwifi

connectWifi 兼容性

Web微信小程序Android 系统版本AndroidiOSHarmonyOS
-->=4.4 && <10.03.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionWifiConnectOption-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

option 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
passwordstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
maunalboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
partialInfoboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.setWifiList(option) @setwifilist

SetWifiList 暂未实现

本 API 是 uni ext api,需下载插件:uni-wifi

setWifiList 兼容性

Web微信小程序AndroidiOSHarmonyOS
--<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a><a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a><a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionWifiOption-Web: -; 微信小程序: -; Android: x; iOS: x; HarmonyOS: xWifi 函数通用入参封装

option 的属性描述

名称类型必备默认值兼容性描述
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.getWifiList(option) @getwifilist

请求获取 Wi-Fi 列表。wifiList 数据会在 onGetWifiList 注册的回调中返回。

本 API 是 uni ext api,需下载插件:uni-wifi

getWifiList 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionWifiOption-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

option 的属性描述

名称类型必备默认值兼容性描述
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.onGetWifiList(UniWifiCallback) @ongetwifilist

监听获取到 Wi-Fi 列表数据事件。

本 API 是 uni ext api,需下载插件:uni-wifi

onGetWifiList 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
callback(wifiInfo: Record<string, any>) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.offGetWifiList(UniWifiCallback) @offgetwifilist

移除获取到 Wi-Fi 列表数据事件的监听函数。

本 API 是 uni ext api,需下载插件:uni-wifi

offGetWifiList 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
callback() => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.getConnectedWifi(option) @getconnectedwifi

获取已连接的 Wi-Fi 信息

本 API 是 uni ext api,需下载插件:uni-wifi

getConnectedWifi 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
optionGetConnectedWifiOptions-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

option 的属性描述

名称类型必备默认值兼容性描述
partialInfoboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
success(res: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
fail(res: UniError) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
complete(res: any) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.onWifiConnected(UniWifiCallback) @onwificonnected

监听连接上 Wi-Fi 的事件

本 API 是 uni ext api,需下载插件:uni-wifi

onWifiConnected 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
callback(wifiInfo: UniWifiResult) => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

UniWifiResult 的属性值 @uniwifiresult-values

名称类型必备默认值兼容性描述
errCodenumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errSubjectstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
errMsgstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
wifiUniWifiInfo-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

wifi 的属性描述

名称类型必备默认值兼容性描述
SSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
BSSIDstring-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
secureboolean-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
signalStrengthnumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x
frequencynumber-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

uni.onWifiConnectedWithPartialInfo(UniWifiCallback) @onwificonnectedwithpartialinfo

监听连接上 Wi-Fi 的事件。

本 API 是 uni ext api,需下载插件:uni-wifi

onWifiConnectedWithPartialInfo 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11-

参数

名称类型必填默认值兼容性描述
callback(wifiInfo: UniWifiInfoWithPartialInfo) => void--

UniWifiInfoWithPartialInfo 的属性值 @uniwifiinfowithpartialinfo-values

名称类型必备默认值兼容性描述
SSIDstring---

参见

uni.offWifiConnected(callback?) @offwificonnected

移除连接上 Wi-Fi 的事件的监听函数。

本 API 是 uni ext api,需下载插件:uni-wifi

offWifiConnected 兼容性

Web微信小程序AndroidiOSHarmonyOS
--3.9.04.11<a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a>

参数

名称类型必填默认值兼容性描述
callback() => void-Web: -; 微信小程序: -; Android: -; iOS: -; HarmonyOS: x

参见

通用类型

GeneralCallbackResult

名称类型必备默认值兼容性描述
errMsgstring-Web: -; 微信小程序: 4.41; Android: -; iOS: -; HarmonyOS: -错误信息