陈帅 7 лет назад
Родитель
Сommit
c1ce6ec86a
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      src/components/SiderMenu/BaseMenu.js

+ 2 - 1
src/components/SiderMenu/BaseMenu.js

@@ -5,6 +5,7 @@ import isEqual from 'lodash/isEqual';
 import memoizeOne from 'memoize-one';
 import { urlToList } from '../_utils/pathTools';
 import { getMenuMatches } from './SiderMenuUtils';
+import { isUrl } from '@/utils/utils';
 import styles from './index.less';
 
 const { SubMenu } = Menu;
@@ -14,7 +15,7 @@ const { SubMenu } = Menu;
 //   icon: 'http://demo.com/icon.png',
 //   icon: <Icon type="setting" />,
 const getIcon = icon => {
-  if (typeof icon === 'string' && icon.indexOf('http') === 0) {
+  if (typeof icon === 'string' && isUrl(icon)) {
     return <img src={icon} alt="icon" className={styles.icon} />;
   }
   if (typeof icon === 'string') {