antd - 如何在自定义字体图标中生成scriptUrl
antd - How to generate scriptUrl in Custom Font Icon
我想添加一个play icon to my antd-Button
component in (React
), I tried to follow antd-Icon documentation and Icon font help但是没有成功生成scriptUrl
来自官方文档:
const MyIcon = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js', // generated by iconfont.cn
});
ReactDOM.render(<MyIcon type="icon-example" />, mountedNode);
scriptUrl
is The URL generated by iconfont.cn project.
The property scriptUrl should be set to import the SVG sprite symbols.
这是我的代码片段:
const PlayIcon = Icon.createFromIconfontCN({
scriptUrl: '', // How to generate url?
});
// Button inside component
<Button shape="circle" onClick={someAction}>
<PlayIcon type="icon-play"/>
</Button>
当您在 iconfont.cn、
中拥有帐户时
转到Icon & Project
转到"My project"
点击"view the online link"获取
旁注,
因为他们放弃了对组件的支持,转而支持 svg 作为组件。你可能更喜欢下载 svg y do
import { Icon } from 'antd';
import PlayIconSvg from 'path/to/playIcon.svg'; // path to your '*.svg' file.
ReactDOM.render(
<Icon component={PlayIconSvg} />,
mountNode
);
我想添加一个play icon to my antd-Button
component in (React
), I tried to follow antd-Icon documentation and Icon font help但是没有成功生成scriptUrl
来自官方文档:
const MyIcon = Icon.createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js', // generated by iconfont.cn
});
ReactDOM.render(<MyIcon type="icon-example" />, mountedNode);
scriptUrl
is The URL generated by iconfont.cn project.The property scriptUrl should be set to import the SVG sprite symbols.
这是我的代码片段:
const PlayIcon = Icon.createFromIconfontCN({
scriptUrl: '', // How to generate url?
});
// Button inside component
<Button shape="circle" onClick={someAction}>
<PlayIcon type="icon-play"/>
</Button>
当您在 iconfont.cn、
中拥有帐户时转到
Icon & Project
转到"My project"
点击"view the online link"获取
旁注,
因为他们放弃了对组件的支持,转而支持 svg 作为组件。你可能更喜欢下载 svg y do
import { Icon } from 'antd';
import PlayIconSvg from 'path/to/playIcon.svg'; // path to your '*.svg' file.
ReactDOM.render(
<Icon component={PlayIconSvg} />,
mountNode
);