mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-30 13:23:49 +00:00
Merge pull request #219 from HeChengjun/master
修正 arrayToTree 函数中 children 拼写错误
This commit is contained in:
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user