Javascript 离子-检查“离子”&引用;打字
我对Ionic和Typescript非常陌生,并且收到了一个应用程序的缺陷,其中出现了一个订单的外壳,但数据都是空白的。 我的代码:Javascript 离子-检查“离子”&引用;打字,javascript,typescript,ionic-framework,Javascript,Typescript,Ionic Framework,我对Ionic和Typescript非常陌生,并且收到了一个应用程序的缺陷,其中出现了一个订单的外壳,但数据都是空白的。 我的代码: // Loop over MONITORS this.monitorArrayLength = this.detail.orderDetailList[i].monitors.length; for (let j = 0; j < this.monitorArrayLength; j++) { this.monitorArray[j] = this.de
// Loop over MONITORS
this.monitorArrayLength = this.detail.orderDetailList[i].monitors.length;
for (let j = 0; j < this.monitorArrayLength; j++) {
this.monitorArray[j] = this.detail.orderDetailList[i].monitors[j];
if (
this.monitorArray[j].serialNum !== null ||
this.monitorArray[j].serialNum !== "" ||
this.monitorArray[j].status !== null ||
this.monitorArray[j].status !== "" ||
this.monitorArray[j].brandModel !== null ||
this.monitorArray[j].brandModel !== "" ||
this.monitorArray[j].docId !== null ||
this.monitorArray[j].docId !== ""
) {
this.showMonitorArray[j] = true; // Show monitor
if (this.monitorArray[j].docId !== null) {
this.pdfIconArray[j] = true; // Show pdf icon
} else {
this.pdfIconArray[j] = false; // Show normal icon
}
} else {
this.showMonitorArray[j] = false; // Don't show monitor
}
}
我上面的代码没有正确检查“”并且数据的外壳仍在显示,而它本不应该显示
这是检查“”的正确语法吗
任何帮助都将不胜感激 这与Ionic或TypeScript无关。你应该改变你的
如果
条件
定义了serialNum,定义了status,定义了brandModel,定义了docId
其中“已定义”表示非null
或“
”
但看起来真的很乱。你可以把它缩短成一个函数
function isDefined(monitor) {
const { serialNum, status, brandModel, docId } = monitor;
return serialNum && status && brandModel && docId;
}
这确保了所有这些值都不正确。这与Ionic或TypeScript无关。你应该改变你的
如果
条件
定义了serialNum,定义了status,定义了brandModel,定义了docId
其中“已定义”表示非null
或“
”
但看起来真的很乱。你可以把它缩短成一个函数
function isDefined(monitor) {
const { serialNum, status, brandModel, docId } = monitor;
return serialNum && status && brandModel && docId;
}
这确保所有这些值都不正确。第一种方法不起作用,监视器外壳仍显示空白数据。我已将函数添加到代码中,但在获得函数后,if语句的语法会是什么?@TheAlmac2未正确编辑if条件。我现在改了。另外,第二种方法:
if(已定义(this.monitorArray[j]))
。第一种方法不起作用,监视器外壳仍显示空白数据。我已将函数添加到代码中,但在获得函数后,if语句的语法会是什么?@TheAlmac2未正确编辑if条件。我现在改了。还有,第二种方法:if(已定义(this.monitorArray[j]))
。
function isDefined(monitor) {
const { serialNum, status, brandModel, docId } = monitor;
return serialNum && status && brandModel && docId;
}