我有一个关于如何在Ajax回调函数中更新对象属性值的问题。 这是代码:
var goldStar = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
fillColor: '',
fillOpacity: 0.8,
scale: 5,
strokeOpacity: 0,
strokeColor: '',
rotation: '',
};
if( some clause) {
$.get("./ajaxEx.php", { nimo: nimo }, function(vesData) {
$(vesData).find("sTarget").each(function() {
if (){ //some clause
goldStar.fillColor = 'red';
goldStar.strokeColor = 'red';
}
}
}
} else {
goldStar.fillColor = 'green';
goldStar.strokeColor = 'green';
}
console.log(goldStar)
console.log输出如下:
Object {path: 1, fillColor: "green", fillOpacity: 0.8, scale: 5, strokeOpacity: 0…}
fillColor: "red"
fillOpacity: 0.8
path: 1
rotation: 0
scale: 5
strokeColor: "red"
strokeOpacity: 0
__proto__: Object
我的问题是为什么对象附加
fillColor:“红色” fillOpacity:0.8 路径:1 轮换:0 规模:5 strokeColor:“红色” strokeOpacity:0
感谢。