Explorar el Código

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

eruca hace 7 años
padre
commit
503dcfd538
Se han modificado 1 ficheros con 5 adiciones y 4 borrados
  1. 5 4
      src/components/SiderMenu/SiderMenu.js

+ 5 - 4
src/components/SiderMenu/SiderMenu.js

@@ -13,18 +13,19 @@ const { SubMenu } = Menu;
 //   icon: 'http://demo.com/icon.png',
 //   icon: <Icon type="setting" />,
 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 (icon.indexOf('http') === 0) {
+      return <img src={icon} alt="icon" className={`${styles.icon} sider-menu-item-img`} />;
+    }
     return <Icon type={icon} />;
   }
+
   return icon;
 };
 
 /**
  * Recursively flatten the data
- * [{path:string},{path:string}] => {path,path2}
+ * [{path:string},{path:string}] => [path,path2]
  * @param  menu
  */
 export const getFlatMenuKeys = menu =>