這是代碼:對象訪問不起作用
(function(Info, undefined) {
var createInfoTableForFeature = function (obj) {
var data2form = {};
data2form.name = obj.name;
data2form.state = obj.state;
data2form.stateid=obj.stateId;
data2form.city = obj.city;
data2form.cityId=obj.cityId;
data2form.sector = obj.sector;
data2form.sectorId=obj.sectorId;
data2form.municipality = obj.municipality;
data2form.municipalityId=obj.municipalityId;
data2form.parish = obj.parish;
data2form.parishId = obj.parishId;
data2form.postcode = obj.postcode;
}
Info.copy2form = function(data){
console.log(data);
}
})(window.Info = window.Info || {});
當我打電話Info.copy2form(data2form)
,data2form
是undefined
哪裏是信息.copy2form被調用? – Chandu 2012-07-12 21:19:08
在哪裏調用'Info.copy2form(data2form)'? 'data2form'只存在於'createInfoTableForFeature'中。 – 2012-07-12 21:19:23
您不應該使用'undefined'作爲參數名稱。 – EricG 2012-07-12 21:21:16