动态生成es6中的class名是不行的但是动态生成属性名是可以的,所以可以通过下面方法实现es5中的类 var randomClassName = 'Xherhahfa'; window[randomClassName] = function (a, b) { this.a = a; this.b = b; }; window[randomClassName].prototype.print = function () { console.log('a:', this.a); console.log('b:', this.b); };
动态生成es6中的class名是不行的
但是动态生成属性名是可以的,所以可以通过下面方法实现es5中的类