Ant Design Pro 官方文档说明 在菜单中使用自定义的 icon
由于 umi 的限制,在 router.config.js
是不能直接只是用组件的,Pro 中暂时支持 使用 ant.design
本身的 icon type,和传入一个 img 的 url。只需要直接在 icon 属性上配置即可,如果是个 url,Pro 会自动处理为一个 img 标签。
如果这样还不能满足需求,可以自定义 getIcon
方法。
如果你想使用 iconfont 的图标,你可以使用ant.desgin的自定义图标.
1. getIcon方法
/* eslint no-useless-escape:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
export function isUrl(path) {
return reg.test(path);
}
import { isUrl } from '../utils/utils';
const getIcon