2
我有一個很大的JavaScript對象字面量,我每次都重複使用很少的修改。建立一個包含大部分對象的變量是很好的,然後每次需要時引用它。合併兩個JavaScript對象
但我該怎麼做?我試圖做到這一點,但沒有奏效:
var settings = {
legend: {
enabled:false
},
yAxis: {
title: {
text: 'Impact'
}
},
tooltip: {
formatter: function() {
return 'Impact: '+ this.y +' points'
}
},
credits: {
enabled: false
},
exporting: {
enabled: false
}
};
jQuery(document).ready(function() {
new Highcharts.Chart({
chart: {
renderTo: 'chart',
defaultSeriesType: 'column',
width: 450
},
title: {
text: 'Comparison of Impact for Male age 23'
},
xAxis: {
categories: [
'Good brain',
'Good humor',
'Good will'
],
},
series: [{
data: [5,2,8]
}],
settings // <-- HERE
});
});
目前物體看起來像'obj.settings.exporting.enabled'。你希望它是'obj.exporting.enabled'嗎? – slebetman 2010-08-05 15:00:07