We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
作用于类的装饰器:其实就是将当前类作为参数传入装饰器函数 作用于类属性的装饰器:调用了Object.defineProperty,如下例子
class Dog { @extendsArgs say() { console.log("hello"); } } function extendsArgs(target,name,descriptor){ target.name = 'Tom', discriptor.writable = false; } let Tom = new Dog(); // Tom.name = 'Tom' Tom.say = function() { console.log("woof !"); } Tom.say() // 'hello'
所以作为类属性的时候实际是如下
let descriptor = { value: function() { console.log("hello"); }, enumerable: false, configurable: true, writable: true }; descriptor = readonly(Dog.prototype, "say", descriptor) || descriptor; Object.defineProperty(Dog.prototype, "say", descriptor);
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: