连接'Clever Helmet' 头盔WiFi - 使用指南
<template>
<view class='containers'>
<view class='device-container'>
<p style='font-size: 18px'> 当前连接的设备名为:</p>
<p style='font-size: 28px'><b>Clever Helmet</b>-WY</p>
</view>
<br>
<view>
<p style='font-size: 18px'> 您可以选择使用头盔的网络进行上网</p>
<br>
</view>
<view class='device-container'>
<button @click='connectWiFi'>连接WiFi</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
ssid: 'WY-6492', // WiFi名称
password: '12345678' // WiFi密码
};
},
methods: {
connectWiFi() {
uni.connectWifi({
SSID: this.ssid, // WiFi名称
password: this.password, // WiFi密码
success: function(res) {
console.log('连接WiFi成功', res);
},
fail: function(res) {
console.log('连接WiFi失败', res);
}
});
}
}
};
</script>
<style>
.containers {
display: flex;
flex-direction: column;
margin-top: 5%;
margin-left: 5%;
margin-right: 5%;
}
.device-container {
margin-top: 10px;
background-color: aliceblue;
border-radius: 5px;
border: 2px solid black;
padding: 10px;
}
</style>
<p>报错uni.connectWifi is not a function内容:这个错误可能是因为uni对象中没有connectWifi方法。请确认您是否引入了uni-app的API,并且在当前的运行环境下是否支持该方法。如果您确定支持该方法,请检查您的代码是否有语法错误或其他逻辑问题。您可以参考uni-app的官方文档和API文档来查找解决方案。</p>
原文地址: https://www.cveoy.top/t/topic/lc0V 著作权归作者所有。请勿转载和采集!