有人可以举一个使用AntD框架使用get Awesome的示例吗?他们提到您可以将SVG与外部图标一起使用。
谢谢
塔班
答案 0 :(得分:0)
答案 1 :(得分:0)
不是直接的,但是您可以自己制作一个IconFont组件。
parcel
|-demo-files
|-some demo files.
|-fonts
|-iconfont.eot
|-iconfont.svg
|-iconfont.ttf
|-iconfont.woff
|-demo.html
|-style.css
|-something not important
$PROJECT_ROOT/src/assets/icons/fonts/
// src/components/IconFont/IconFont.jsx
import React from 'react';
import classNames from 'classnames';
import './icon.less';
const IconFont = ({ type, active, className, size = 16, style, ...rest }) => (
<i
{...rest}
style={{ fontSize: size, ...style }}
className={classNames(
'icon',
{
'icon_active': active,
[`icon-${type}`]: type,
},
className
)}
/>
);
export default IconFont;
现在您可以使用该组件了。
// src/components/IconFont/icon.less
@font-face {
font-family: 'your-iconfont-name';
src: url('../../assets/icons/fonts/iconfont.eot');
src: url('../../assets/icons/fonts/iconfont.eot#iefix') format('embedded-opentype'), url('../../assets/icons/fonts/iconfont.ttf') format('truetype'), url('../../assets/icons/fonts/iconfont.svg#live') format('svg');
}
.icon {
font-family: 'your-iconfont-name' !important; // font-size: 16px;
font-style: normal;
transition: 0.3s;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
vertical-align: middle;
// things under refer to style.css in unzipped files.
&.icon-female:before {
content: "\e901";
}
&.icon-male:before {
content: "\e902";
}
&.icon-close:before {
content: "\e900";
}
}