我有以下代码:
for(workload.elements 中的变量索引) { var arr = []; var resourceIdentifiers = {}; 变量元素信息 = {}; var metadataModified = {};
elementinfo = workload.elements[index];
arr[index] = workload.elements[index].uri;
if(workload.elements[index].parameters.imageUri)
{
arr.push(workload.elements[index].parameters.imageUri);
}
resourceIdentifiers = arr.join(',');
console.log('uri' + resourceIdentifiers);
// connects with mysql and fetch data
mysql.elementlevelpricing(resourceIdentifiers, function(result){
elementlevelpricingSummary = JSON.stringify(result,null,2);
console.log('resultin' + elementlevelpricingSummary);
});
console.log('resultout' + JSON.stringify(elementlevelpricingSummary,null,2))
}
当在调用的函数 mysql.elementlevelpricing() 之外访问时,变量 elementlevelpricingSummary 的值变为空 {}。