javascript - 未处理的拒绝(TypeError):无法读取未定义的属性“销毁”
问题描述
反应 / JS 菜鸟在这里。我收到以下错误 - “未处理的拒绝(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 中运行良好,但是一旦我尝试将 react 加入混合中,什么都没有。谢谢 - 我已经尝试了好几天了。
解决方案
推荐阅读
- protocols - SSH 和 HTTP 有什么区别?
- google-bigquery - BigQuery 联合数据源:命令行界面中的 CSV 选项?
- node.js - 如何检查 Express Framework 中的请求中是否存在至少一个文件
- c# - ASP.NET Boilerplate 多个数据库和 DbContexts
- swift - iOS12 sirishortcut-成功捐赠交互但在App下设置sir&search找不到
- java - 从休眠 3 升级到休眠 5 后出现 InvalidDataAccessApiUsageException
- zend-framework - 使用 RowGateway 创建行
- android - 如何在android中找到谷歌浏览器的绝对路径
- javascript - Vue.js:在脚本中设置评估/v-bound 属性
- javascript - 将强度点数组转换为标记