0
我有一個對象「配置」和ID「ID」, 我想創建對象的數組具有下列結構:角/打字稿創建的對象與動態密鑰
[
"id" : {
"config1: ...
"config2: ...
"config3: ...
}
"id2" : {
"config1: ...
"config2: ...
"config3: ...
}
]
我試圖下面的代碼:
garage.push({this.id : this.config });
但它會導致編譯錯誤,如:
ERROR in component.ts (168,51): An object literal cannot have multiple properties with the same name in strict mode.
我怎麼能做這個工作?
'garage'是如何聲明的?它的類型是什麼? –
let garage = []; – Moshe
_「編譯錯誤」_?可以將這些添加到您的問題? – evolutionxbox