class User{
name:string
get info(){
return '222';
}
}
const ab = new User();
console.log(ab.info);
这样可以输出222
class User{
name:string
info(){
return '222';
}
}
const ab = new User();
console.log(ab.info);
这样却不能输出222,非得使用ab.info()才行
可以去了解一下对象的 getter 和 setter
具体可以看 MDN 的解释
https://developer.mozilla.org...