为什么我得到未定义错误的属性
Why do I get property of undefined error?
我收到以下错误。
Uncaught TypeError: Cannot read property 'on' of undefined
当我添加代码行时会发生这种情况
let ServicePlugin = new ServicePlugin();
知道我做错了什么吗?下面是完整的代码。
'use strict';
class ServicePlugin {
constructor(api) {
this._api = api;
this._api.on('ready', () => this._apiReady());
this._api.on('saveSuccess', () => this._apiSuccess());
}
_apiReady() {
console.log('Plugin Ready')
}
_apiSuccess() {
console.log('Plugin Success');
}
}
let ServicePlugin = new ServicePlugin();
ServicePlugin._apiReady();
module.exports = ServicePlugin;
在
实例化类时,必须提供 learnosity
参数(无论该参数是什么)。 AnnServicePlugin
期望它:
let annServicePlugin = new AnnServicePlugin(learnosity);
当然,learnosity
对象必须具有预期的on
方法。
相关文章:
- Jqx图表给出错误错误:
属性高度=“-1”的负值无效 - 谷歌地图 API 错误:属性<航点>::中的错误
- 未捕获的类型错误:属性'$'对象[object Window]的
- 错误“属性'日期选择器'在带有打字稿的类型'IAugmentedJQuery'上不存在
- 类型错误属性 然后是未定义的
- 挖空引用错误 - 属性在存在时未定义
- “语法错误:属性列表后缺少}” 如何使Javascript符号证明
- 错误:
属性宽度=“NaN” 6d3.v3.min.js:1 的值无效: 属性 x=“NaN” - Ajax 和 JS on select_taf;语法错误:属性列表后缺少 }
- 获取错误语法错误:属性列表 url 后缺少 }:http://localhost/mcportal/public/pos
- Google Maps JavaScript : 未捕获错误: 属性
- 类型错误:属性 1 不可配置,无法删除
- Javascript/HTML错误“属性”selectReason“的值为null或未定义,而不是函数对象
- Mootools'未捕获的类型错误:属性'容器'对象#<对象>不是函数'添加
- 错误:
属性残雪=“NaN"在dimple.js - D3.js错误:
属性用于折线图 - 错误:d3.v4.min.js:3错误:<属性宽度:期望长度,"
- SVG路径错误"d"属性
- 错误:
d =“属性.饼状图 - 未捕获的类型错误:属性'fn'对象[object DOMWindows]的不是函数