【发布时间】:2019-01-17 16:29:11
【问题描述】:
在我的应用程序中,如果来自服务的数据未定义或为空,我的 html 将不会加载,我将收到“数据未定义”错误 所以我想用lodash,但不知道怎么用..
在我下面的 ts 文件中
this._PartService.GetDataValues().subscribe(
result => {
this.distributionData = this._PartService.part_data.partMasterDataCompleteList[0].partMasterData.plantSupplies.plantSupply
}
如果数据不存在,我将得到“partMasterDataCompleteList”作为 undefiend 或 null,所以我正在尝试使用 Lodash,但我不知道如何使用它
【问题讨论】:
-
尝试使用 lodash 是什么意思?
-
如果它可以是未定义的,你应该处理这种情况。
标签: javascript angular typescript angular5 lodash