给js对象赋值,赋值key

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_sAd...展开

pastResult是数组,所以只能用0,1,2

1
2
3
4
5
6
7
8
9
// 用对象
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']);
原文地址:https://www.cnblogs.com/xiaoleiel/p/8308572.html