如何使用foo
装饰器更改TestClass
中DefaultValue
的值?
class TestClass {
@DefaultValue('bar')
private foo;
}
export const DefaultValue = (val: any): PropertyDecorator => {
return (target: any, propertyKey: string | symbol) => {
// Change the value of the decorated property
this[propertyKey] = val; // DOESN'T WORK!
};
}
不起作用:this[propertyKey] = val;