这是我正在尝试做的 - 这是伪代码,不起作用.有谁知道如何实现这一目标:
// Define the class
MyClass = Class.extend({});
// Store the class name in a string
var classNameString = 'MyClass';
// Instantiate the object using the class name string
var myObject = new classNameString();
Run Code Online (Sandbox Code Playgroud) 我试图开始某种工作:
export class SomeComponent {
constructor() {
let className: string = "TheClass";
/* should be the same as .. = new TheClass() */
let superSpecial = new className();
}
}
Run Code Online (Sandbox Code Playgroud)
我还没有弄清楚该怎么做?有人可以帮我吗?