//根据后台数据格式化菜单
function formatMenu(data) {
return data.map(function (item) {
if (!item) {
return null;
}
var path = item.path, name = item.menuName, id = item.id;
var result = {
path: path,
name: name,
id: id
};
if (item.pid > 0) {
result.exact = true;
}
if (item.ch) {
var children = formatMenu(item.ch);
result.children = children;
}
return result;
}).filter(function (item) {
return item
});
}