typescript - 类的属性作为类并访问父属性
问题描述
描述我在这里问的内容非常棘手,因此我将仅使用一个假设示例:
import { Address } from "./Address";
export class Customer {
public firstName: string;
public address: Address;
public constructor(firstName: string, city: string) {
this.firstName = firstName;
this.address = new Address(city);
}
}
和
export class Address {
public city: string;
public constructor(city: string) {
this.city = city;
// Can I access the Customer.firstName from here?
}
}
根据我在Address
上面的类中的评论,是否可以访问启动此address
属性的类的属性(当然不将其作为 arg 发送)?在这种情况下,Customer
实例。
希望这有意义吗?
解决方案
推荐阅读
- python - Django全文搜索:如何组合多个查询和向量?
- r - 如何规范化栅格堆栈?
- java - elasticsearch渗透java api示例
- json - 从 JSON 转换为 Python 对象||如何访问此字典元素
- android - android.intent.action.ACTION_OPEN_DOCUMENT_TREE 是否仍然需要 setType()?
- python - 获取嵌套字典中列表的值
- java - 如何检查 RDS 令牌是否有效
- java - 我的代码无法识别特殊字符
- html - Multiple clickTags for html5 file in Google AdManager
- java - 选择下拉选项时插入数据,MySQL、JAVA、JSP