diff --git a/src/SiderMenu/BaseMenu.tsx b/src/SiderMenu/BaseMenu.tsx
index 43ac39fc..faae6c8f 100644
--- a/src/SiderMenu/BaseMenu.tsx
+++ b/src/SiderMenu/BaseMenu.tsx
@@ -9,7 +9,7 @@ import { MenuMode, MenuProps } from 'antd/es/menu';
import { MenuTheme } from 'antd/es/menu/MenuContext';
import defaultSettings, { PureSettings } from '../defaultSettings';
import { getSelectedMenuKeys } from './SiderMenuUtils';
-import { isUrl, getOpenKeysFromMenuData } from '../utils/utils';
+import { isUrl, getOpenKeysFromMenuData, isImg } from '../utils/utils';
import {
MenuDataItem,
@@ -73,7 +73,7 @@ let IconFont = createFromIconfontCN({
// icon: ,
const getIcon = (icon?: string | React.ReactNode): React.ReactNode => {
if (typeof icon === 'string' && icon !== '') {
- if (isUrl(icon)) {
+ if (isUrl(icon) || isImg(icon)) {
return (
(
diff --git a/src/utils/utils.ts b/src/utils/utils.ts
index 964185a7..442e293f 100644
--- a/src/utils/utils.ts
+++ b/src/utils/utils.ts
@@ -18,6 +18,11 @@ export const isBrowser = () =>
typeof window.document !== 'undefined' &&
!isNode;
+/** 判断是否是图片链接 */
+export function isImg(path: string): boolean {
+ return /\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
+}
+
export function guid() {
return 'xxxxxxxx'.replace(/[xy]/g, (c) => {
// eslint-disable-next-line no-bitwise