在这里反应/ JS noob。尝试运行以下命令时,出现以下错误-“未处理的拒绝(TypeError):无法读取未定义的属性'destroy'”-
import React from 'react';
const { Client } = require('tplink-smarthome-api');
let client = new Client()
const plug = client.getDevice({host: '192.168.1.10'}).then((device)=>{
device.getSysInfo().then(console.log);
device.setPowerState(true);
});
我尝试使用--
之类的异步函数const toggle = async () => {
const plug = await client.getPlug({ host: '192.168.1.10' })
plug.setPowerState(true)
}
上面的代码一直工作到plug.setPowerState(true)。这将导致“未处理的拒绝(TypeError):无法读取未定义的属性'destroy'”。这在node.js中运行良好,但是当我尝试将反应加入混合时,什么也没有。谢谢-我已经尝试了好几天了。