diff --git a/components/icon/demo/scriptUrl.md b/components/icon/demo/scriptUrl.md new file mode 100644 index 0000000000..5087be7983 --- /dev/null +++ b/components/icon/demo/scriptUrl.md @@ -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 `` 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( +
+ + + + +
, + mountNode, +); +``` diff --git a/components/icon/index.en-US.md b/components/icon/index.en-US.md index f7afdcc831..94a6caf99a 100644 --- a/components/icon/index.en-US.md +++ b/components/icon/index.en-US.md @@ -24,7 +24,7 @@ ReactDOM.render(, mountNode); | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | -| className | className of Icon | `string` | - | | +| className | className of Icon | `string` | - | | | style | Style properties of icon, like `fontSize` and `color` | CSSProperties | - | | | spin | Rotate icon with animation | boolean | false | | | rotate | Rotate by n degrees (not working in IE9) | number | - | | @@ -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. diff --git a/components/icon/index.zh-CN.md b/components/icon/index.zh-CN.md index eff3ddfce8..51a0958720 100644 --- a/components/icon/index.zh-CN.md +++ b/components/icon/index.zh-CN.md @@ -106,7 +106,7 @@ ReactDOM.render(, 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` 图标 `` 组件设置额外的属性 | `{ [key: string]: any }` | {} | | 在 `scriptUrl` 都设置有效的情况下,组件在渲染前会自动引入 [iconfont.cn](http://iconfont.cn/) 项目中的图标符号集,无需手动引入。 diff --git a/package.json b/package.json index 14201983be..5ebe4e6e65 100644 --- a/package.json +++ b/package.json @@ -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",