-
Couldn't load subscription status.
- Fork 675
Description
(这篇文章的demo有问题:https://jkchao.github.io/typescript-book-chinese/tips/metadata.html#%E5%9F%BA%E7%A1%80))。
原文:
譬如在 vue-property-decorator 6.1 及其以下版本中,通过使用 Reflect.getMetadata API,Prop Decorator 能获取属性类型传至 Vue,简要代码如下:
function Prop(): PropertyDecorator { return (target, key: string) => { const type = Reflect.getMetadata('design:type', target, key); console.log(${key} type: ${type.name}`);
// other...
};
}
class SomeClass {
@prop()
public Aprop!: string;
}
`
代码运行有问题。改成如下则没问题:
function Prop(): Function { return (target, key: string) => { const type = Reflect.getMetadata('design:type', target, key); console.log(${key} type: ${type.name}`);
// other...
};
}
class SomeClass {
@prop()
public Aprop!: string;
}
`