<template>
<view class="page">
<view style="display: block; height: 50px;"></view>
<view class="gc-box">
<button @click="getWifiList">连接wifi</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {},
methods: {
getWifiList() {
uni.startWifi({
success: (res) => {
console.log("startWifistartWifi"+JSON.stringify(res));
uni.connectWifi({
// "SSID":'abc',
// "password":'88888888',
"maunal": true,
"partialInfo": true,
success: (res1) => {
console.log("connectWificonnectWificonnectWifi"+JSON.stringify(res1));
},
fail: (err) => {
console.log(err);
}
});
},
fail: (err) => {
console.log(err);
},
complete: () => {
uni.onWifiConnected((winfo) => {
//不会跳这里
console.log("onWifiConnected"+JSON.stringify(winfo));
})
}
})
}
}
}
</script>
<style>
.item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
border-bottom: 2rpx solid #ddd;
padding: 16rpx 0;
}
.item .title {
flex: 1;
}
input {
border-bottom: 2rpx solid #ddd;
}
</style>
1 个回复
qjr
Android以上直连只能通过写插件形式去实现了,uts和原生插件都可以