class Collection {
}
class Model extends Collection {
save() {
console.log('original Implementation')
}
}
@Persistable
class User extends Model {
}
function Persistable(target: any) {
target.save = function () { console.log('override') }
}
let user = new User()
user.save() // prints original Implementation
我想使用装饰器覆盖一个类方法。不幸的是,覆盖不起作用,原始方法仍然被执行