const app = getApp(); Component({ data: { wifiList: [] }, // 生命周期方法 lifetimes: { attached() { }, detached() { } }, // 组件的方法 methods: { getWiFiList() { wx.showLoading({ title: "正在获取Wi-Fi列表...", mask: true }); const activeProtocol = app.globalData.ppScale.activeProtocol; if (!activeProtocol) { wx.hideLoading(); wx.showToast({ title: '设备未连接,请重试', icon: 'none' }); return; } activeProtocol.dataFindSurroundDevice((res) => { console.log("connectedDevice ===》dataFindSurroundDevice", res); wx.hideLoading(); this.setData({ wifiList: Array.isArray(res) ? res : [] }); }); }, selectDevice(e) { this.triggerEvent('wifiEvent', { status: true, data: e.currentTarget.dataset.item }); } } });