📜  TypeScript 类私有字段示例 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:23.593000             🧑  作者: Mango

代码示例1
class Animal {  private name: string;
  constructor(theName: string) {    this.name = theName;  }}
new Animal("Cat").name;Property 'name' is private and only accessible within class 'Animal'.2341Property 'name' is private and only accessible within class 'Animal'.Try