docs: update createFromIconfontCN scriptUrl new array usage (#23704)

* scriptUrl新增数组类型支持,增加文档说明,修改@ant-design/icons最低版本号

* 增加scriptUrl支持数组的代码演示,增加类型说明

* Icon 修改代码演示标题,补充文档

* 根据建议修改文档格式

* 增加scriptUrl为数组时候的覆盖关系说明

* 修改覆盖说明文案
pull/23721/head
Baic 5 years ago committed by GitHub
parent 4119c9324a
commit 7790046ce2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,35 @@
---
order: 4
title:
zh-CN: 使用 iconfont.cn 的多个资源
en-US: Multiple resources from iconfont.cn
---
## zh-CN
`@ant-design/icons@4.1.0` 以后,`scriptUrl` 可引用多个资源,用户可灵活的管理 [iconfont.cn](http://iconfont.cn/) 图标。如果资源的图标出现重名,会按照数组顺序进行覆盖。
## en-US
You can use `scriptUrl` as an array after `@ant-design/icons@4.1.0`, manage icons in one `<Icon />` from multiple [iconfont.cn](http://iconfont.cn/) resources. If icon with a duplicate name in resources, it will overrided in array order.
```jsx
import { createFromIconfontCN } from '@ant-design/icons';
const IconFont = createFromIconfontCN({
scriptUrl: [
'//at.alicdn.com/t/font_1788044_0dwu4guekcwr.js', // icon-javascript, icon-java, icon-shoppingcart (overrided)
'//at.alicdn.com/t/font_1788592_a5xf2bdic3u.js', // icon-shoppingcart, icon-python
],
});
ReactDOM.render(
<div className="icons-list">
<IconFont type="icon-javascript" />
<IconFont type="icon-java" />
<IconFont type="icon-shoppingcart" />
<IconFont type="icon-python" />
</div>,
mountNode,
);
```

@ -111,7 +111,7 @@ The following options are available:
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| scriptUrl | The URL generated by [iconfont.cn](http://iconfont.cn/) project. | string | - | |
| scriptUrl | The URL generated by [iconfont.cn](http://iconfont.cn/) project. Support `string[]` after `@ant-design/icons@4.1.0`. | string \| string[] | - | |
| extraCommonProps | Define extra properties to the component | `{ [key: string]: any }` | {} | |
The property `scriptUrl` should be set to import the SVG sprite symbols.

@ -106,7 +106,7 @@ ReactDOM.render(<MyIcon type="icon-example" />, mountedNode);
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| --- | --- | --- | --- | --- |
| scriptUrl | [iconfont.cn](http://iconfont.cn/) 项目在线生成的 `js` 地址 | string | - | |
| scriptUrl | [iconfont.cn](http://iconfont.cn/) 项目在线生成的 `js` 地址`@ant-design/icons@4.1.0` 之后支持 `string[]` 类型 | string \| string[] | - | |
| extraCommonProps | 给所有的 `svg` 图标 `<Icon />` 组件设置额外的属性 | `{ [key: string]: any }` | {} | |
`scriptUrl` 都设置有效的情况下,组件在渲染前会自动引入 [iconfont.cn](http://iconfont.cn/) 项目中的图标符号集,无需手动引入。

@ -96,7 +96,7 @@
"ie >= 11"
],
"dependencies": {
"@ant-design/icons": "^4.0.0",
"@ant-design/icons": "^4.1.0",
"@ant-design/react-slick": "~0.25.5",
"array-tree-filter": "^2.1.0",
"classnames": "~2.2.6",

Loading…
Cancel
Save