答案可能很明显,但我看不到
我有一个 JavaScript 对象 virtualTable。我写的 :
parseInt(virtualTable["resource_" + resourceId])
它返回NaN
我查看virtualTable["resource_" + resourceId]
警报,答案是“690”
如果我提醒parseInt("690")
它工作正常并返回 690
那有什么问题呢?
整个代码:
if(!virtualTable.hasOwnProperty("resource_" + resourceId)) {
virtualTable["resource_" + resourceId] = "\"" + minutesToFill + "\"";
}
var timeForTarget = (target.end.getTime() - target.start.getTime()) / 60000;
var timeInVirtualTable;
var tooltipInTarget
if(virtualTable["resource_" + resourceId].indexOf("_") == -1) {
timeInVirtualTable = parseInt(virtualTable["resource_" + resourceId]);
tooltipInTarget = "";
} else {
timeInVirtualTable = parseInt(virtualTable["resource_" + resourceId].substring(0, virtualTable["resource_" + resourceId].indexOf("_")));
tooltipInTarget = virtualTable["resource_" + resourceId].substring(virtualTable["resource_" + resourceId].indexOf("_"));
}