我正在本地化一个菜单,并且我想以这种方式将声明的数组分配给对象属性:
var menuListLocal=["Home","Play","Options","Exit"];
var menu_Controller={
_menuList: menuListLocal,
// .... //
}
抱歉,如果太明显了。
谢谢。
最佳答案
记住 ropstah 的评论,你所拥有的应该有效。
var menuListLocal=["Home","Play","Options","Exit"];
var menu_Controller={
_menuList: menuListLocal,
_other: 'Something'
};
使用示例:
var home = menuListLocal._menuList[0];
关于javascript - 将现有的 javascript 数组分配给对象表示法中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1307244/