onGetWifiList
简介
Wi-Fi 扫描结果事件监听
入参
无
callback 返回参数说明
Object res
参数 | 类型 | 说明 |
---|---|---|
wifiList | Array.<wifiInfo> | Wi-Fi 信息 |
示例代码
Page({
data: {
wifiStatus: '',
getWifiList: 0,
},
onReady() {
this.startWifi().then(() => {
this.onGetWifiList();
});
},
startWifi() {
const _that = this;
return new Promise((resolve, reject) => {
dlt.startWifi({
success: function (res) {
console.log('startWifi success', res);
_that.setData({
wifiStatus: 'startWifi',
});
resolve(res);
},
complete: function (res) {
console.log('startWifi complete', res);
},
fail: function (res) {
console.log('startWifi fail', res);
reject(res);
},
});
});
},
onGetWifiList() {
const _that = this;
dlt.onGetWifiList((res) => {
console.log('onGetWifiList==: ', res);
_that.setData({
getWifiList: res.length,
});
});
},
});