Dell老师,target.prototype为空是什么原因?
来源:6-9 装饰器的执行顺序
 
			WuLi滔滔
2022-03-31
在ts.config.json的target为es2015的前提下
function showData(target: typeof User) {
  console.log(Object.keys(target.prototype)) // 输出[],导致for循环没有执行
  for (let key in target.prototype) {
    const data = Reflect.getMetadata("data", target.prototype, key);
    console.log(data);
  }
}
但是在target为es3时
function showData(target: typeof User) {
  console.log(Object.keys(target.prototype)) // 输出["getName","getAge"]
  for (let key in target.prototype) {
    const data = Reflect.getMetadata("data", target.prototype, key);
    console.log(data);
  }
}
这是为什么呢?
写回答
	1回答
- 
				  Dell 2022-04-04 这肯定是兼容性问题了 022022-06-12
相似问题
