Merge pull request #219 from HeChengjun/master

修正 arrayToTree 函数中 children 拼写错误
This commit is contained in:
zuiidea
2017-04-26 16:55:17 +08:00
committed by GitHub
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ const Menus = ({ siderFold, darkTheme, location, handleClickNavMenu, navOpenKeys
// 递归生成菜单
const getMenus = (menuTreeN, siderFoldN) => {
return menuTreeN.map(item => {
if (item.chindren) {
if (item.children) {
if (item.mpid) {
levelMap[item.id] = item.mpid
}
@@ -25,7 +25,7 @@ const Menus = ({ siderFold, darkTheme, location, handleClickNavMenu, navOpenKeys
{(!siderFoldN || menuTree.indexOf(item) < 0) && item.name}
</span>}
>
{getMenus(item.chindren, siderFoldN)}
{getMenus(item.children, siderFoldN)}
</Menu.SubMenu>
)
}
+3 -3
View File
@@ -79,7 +79,7 @@ const queryArray = (array, key, keyAlias = 'key') => {
* @param {String} children
* @return {Array}
*/
const arrayToTree = (array, id = 'id', pid = 'pid', chindren = 'chindren') => {
const arrayToTree = (array, id = 'id', pid = 'pid', children = 'children') => {
let data = lodash.cloneDeep(array)
let result = []
let hash = {}
@@ -90,8 +90,8 @@ const arrayToTree = (array, id = 'id', pid = 'pid', chindren = 'chindren') => {
data.forEach((item) => {
let hashVP = hash[item[pid]]
if (hashVP) {
!hashVP[chindren] && (hashVP[chindren] = [])
hashVP[chindren].push(item)
!hashVP[children] && (hashVP[children] = [])
hashVP[children].push(item)
} else {
result.push(item)
}