Commit 529dff86 authored by eruca's avatar eruca Committed by 陈帅

减少一次判断,及修正一个文档错误

parent 4903acb4
...@@ -13,18 +13,19 @@ const { SubMenu } = Menu; ...@@ -13,18 +13,19 @@ const { SubMenu } = Menu;
// icon: 'http://demo.com/icon.png', // icon: 'http://demo.com/icon.png',
// icon: <Icon type="setting" />, // icon: <Icon type="setting" />,
const getIcon = icon => { const getIcon = icon => {
if (typeof icon === 'string' && icon.indexOf('http') === 0) {
return <img src={icon} alt="icon" className={`${styles.icon} sider-menu-item-img`} />;
}
if (typeof icon === 'string') { if (typeof icon === 'string') {
if (icon.indexOf('http') === 0) {
return <img src={icon} alt="icon" className={`${styles.icon} sider-menu-item-img`} />;
}
return <Icon type={icon} />; return <Icon type={icon} />;
} }
return icon; return icon;
}; };
/** /**
* Recursively flatten the data * Recursively flatten the data
* [{path:string},{path:string}] => {path,path2} * [{path:string},{path:string}] => [path,path2]
* @param menu * @param menu
*/ */
export const getFlatMenuKeys = menu => export const getFlatMenuKeys = menu =>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment