我正在为Aurelia制作一个插件,需要一个类装饰器
我已经看了一些例子,到目前为止我已经把它放在了一起("伪ish"代码)
return function addAndCall(target: any): any {
var original = target;
var newConstructor = function (...args) {
original.apply(this, args);
this.newAttribute = "object instance value";
ExternalModule.externalFunction(this);
};
newConstructor.prototype = Object.create(original.prototype);
newConstructor.prototype.constructor = original;
return <any>newConstructor;
}
Run Code Online (Sandbox Code Playgroud)
但
任何帮助和解释将不胜感激!