Skip to content

Commit 0a0a6a6

Browse files
committed
fix: icon extraCommonProps not work #737
1 parent 1704ce4 commit 0a0a6a6

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Diff for: components/icon/IconFont.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Icon from './index';
2+
import { mergeProps } from '../_util/props-util';
23

34
const customCache = new Set();
45

56
export default function create(options) {
6-
const { scriptUrl } = options;
7+
const { scriptUrl, extraCommonProps = {} } = options;
78

89
/**
910
* DOM API required.
@@ -43,7 +44,8 @@ export default function create(options) {
4344
if (children) {
4445
content = children;
4546
}
46-
return <Icon {...{ ...data, props: restProps, on: listeners }}>{content}</Icon>;
47+
const iconProps = mergeProps(extraCommonProps, data, { props: restProps, on: listeners });
48+
return <Icon {...iconProps}>{content}</Icon>;
4749
},
4850
};
4951
return Iconfont;

Diff for: components/icon/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The following options are available:
7272
| Property | Description | Type | Default |
7373
| --- | --- | --- | --- |
7474
| scriptUrl | The URL generated by [iconfont.cn](http://iconfont.cn/) project. | string | - |
75-
| extraCommonProps | Define extra properties to the component | `{ [key: string]: any }` | {} |
75+
| extraCommonProps | Define extra properties to the component | `{ class, attrs, props, on, style }` | {} |
7676

7777
The property `scriptUrl` should be set to import the SVG sprite symbols.
7878

Diff for: components/icon/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ new Vue({
7070
| 参数 | 说明 | 类型 | 默认值 |
7171
| --- | --- | --- | --- |
7272
| scriptUrl | [iconfont.cn](http://iconfont.cn/) 项目在线生成的 `js` 地址 | string | - |
73-
| extraCommonProps | 给所有的 `svg` 图标 `<Icon />` 组件设置额外的属性 | `{ [key: string]: any }` | {} |
73+
| extraCommonProps | 给所有的 `svg` 图标 `<Icon />` 组件设置额外的属性 | `{ class, attrs, props, on, style }` | {} |
7474

7575
`scriptUrl` 都设置有效的情况下,组件在渲染前会自动引入 [iconfont.cn](http://iconfont.cn/) 项目中的图标符号集,无需手动引入。
7676

0 commit comments

Comments
 (0)