怎麼可以將我的數組轉換:轉換數組對象數組
["Collaboration", "Personal", "Services", "Financial", "Enginerring", "Infrastructure", "Application", "null"]
對象的數組:
["title": "Collaboration", "title":"Personal", "title":"Services", "title":"Financial", "title":"Enginerring", "title":"Infrastructure", "title":"Application", "title":"null"]
我做這樣的事情:
var mainmenu = [];
for(var i=0; menus.length > i;i++){
mainmenu[i] = "{title:"+menus[i]+"}";
}
但我得到了:
["{title:Collaboration}", "{title:Personal}", "{title:Services}", "{title:Financial}", "{title:Enginerring}", "{title:Infrastructure}", "{title:Application}"]
那麼怎麼可能不用雙引號呢?
什麼你看作爲一個 「對象數組」 並不在JavaScript中存在。你的意思是'[{title:「Collaboration」},{...},...]'? – 2016-02-12 16:43:42