angular.forEach(rightOptions.options,function(v,k){ _label=v.group; varsubInsertMenus={}; if(!rightMenus[_label]){//判断父节点是否存在 subMenu(v); subInsertMenus[v.label]=srm; varrm={ "label":_label,"separator_before":false,"separator_after":false,"submenu":subInsertMenus }; rightMenus[_label]=rm; }else{ subMenu(v); rightMenus[_label].submenu[v.label]=srm; } });原文链接:https://www.f2er.com/angularjs/145422.html