test-whiteboard
Version:
https://gitlab.gridsum.com/gov_law_tech/FrontEnd/whiteboard
25 lines (20 loc) • 644 B
JavaScript
function copyProperties(target, source) {
for (let key of Reflect.ownKeys(source)) {
if (key !== "constructor" && key !== "prototype" && key !== "name") {
let desc = Object.getOwnPropertyDescriptor(source, key);
Object.defineProperty(target, key, desc);
}
}
}
var mixin = function (...mixins) {
class Mix {
}
// 以编程方式给Mix类添加
// mixins的所有方法和访问器
for (let mixin of mixins) {
copyProperties(Mix, mixin);
copyProperties(Mix.prototype, mixin.prototype);
}
return Mix;
}
export default mixin;