我可以将mixins添加到函数原型中,但似乎我无法使用类原型来实现它:
例如code
var mixins = { doSmth() {} }
function F() {}
Object.assign(F.prototype, mixins);
new F().doSmth();
class C {}
Object.assign(C.prototype, mixins);
new C().doSmth();
会导致这些错误
8: Object.assign(C.prototype, mixins);
^ property `doSmth` of object literal. Property not found in
8: Object.assign(C.prototype, mixins);
^ C
9: new C().doSmth();
^ property `doSmth`. Property not found in
9: new C().doSmth();
^ C
如何将mixins添加到类中?