给js对象赋值,如何赋值key?
varpastResult=[];pastResult.push(feature.attributes.F_iID);pastResult.push(feature.at...
var pastResult = []; pastResult.push(feature.attributes.F_iID); pastResult.push(feature.attributes.F_sName); pastResult.push(feature.attributes.F_sAddress);
得到的结果是:
想要把默认的0、1、2,改成F_iID、F_sName、F_sAddress,
该怎么做? 展开
得到的结果是:
想要把默认的0、1、2,改成F_iID、F_sName、F_sAddress,
该怎么做? 展开
1个回答
展开全部
pastResult是数组,所以只能用0,1,2
// 用对象
var pastResult = {};
pastResult['F_iID'] = feature.attributes.F_iID;
pastResult['F_sName'] = feature.attributes.F_sName;
pastResult['F_sAddress'] = feature.attributes.F_sAddress;
alert(pastResult['F_iID']);
alert(pastResult['F_sName']);
alert(pastResult['F_sAddress']);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询