angularjs - angularjs继承objectprototype只能是对象或者null
问题描述
我认为这将是一个简单的基类和子类任务,但这个错误正在抛出我。
我创建了一个这样的基类:
module A.B.C {
export class instructionBase {
constructor(
var1: class1,
var2: class2,
...etc for 10 injected classes) { //init code }
method1(){}
method2(){}
}
}
我继承的类是这样的:
namespace A.B.C {
export class instructionComponent extends instructionBase {
static $inject = ["", "", ""...for 10 times]
constructor(
var1: class1,
etc for 10 times) {
super(var1, for 10 times)
}
}
// Register the component
angular.module("myApp.abc")
.component("instructioncomponent", {
templateUrl: "/.../instruction.component.html",
controllerAs: "vm",
transclude: true,
controller: instructionComponent
});
}
在运行时我收到此错误:
未捕获的类型错误:对象原型可能只是一个对象或空:未定义在 setPrototypeOf () at __extends (someOtherClassICreatedALongTimeAgo.js:6) at instrumentComponent.ts:4 at ABC (instrumentComponent.ts:4) at ABAB(instrumentComponent.ts:45 ) 在 A (instrumentComponent.ts:45) 在 instrumentComponent.ts:45
令我感兴趣的是,在错误的第 6 行,命名空间部分重复了两次。我是否有意外的循环引用?
从错误中查看这个类(someOtherClassICreatedALongTimeAgo),它还扩展了一个基类,所以我必须在某处交叉电线。
TIA
解决方案
最有可能在您尝试扩展instructionBase
它时是undefined
. 那将是我的猜测。如果您想确定这一点,请尝试将其放在同一个文件中
推荐阅读
- python - 如何使 PYTHON 中的 try 函数只执行一次,而 except 执行多次?
- php - 从包含链接的文本文件的每一行中删除换行符并在 iframe 中显示这些链接
- php - 如何将可折叠面板的状态保存到会话变量?
- java - 是否可以将 Java 的 Socket API 与 Spring-Boot Web 应用程序一起使用?
- r - 计算同一data.frame中两个长/纬点之间的距离
- python - 如何保存在交互模式下创建的变量?
- python-3.x - 进度条滞后于单独线程 tkinter 上的计算密集型函数
- android - NativeScript ListView 没有更新
- visual-studio - 为什么我可以在 VS2019 中安装 NuGet v4.0.10 而在 VS2012 中却不能?
- ios - 尝试在时间间隔后清除粘贴板