Skip to content

Commit

Permalink
fix: icon extraCommonProps not work vueComponent#737
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed May 26, 2019
1 parent 1704ce4 commit 0a0a6a6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions components/icon/IconFont.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Icon from './index';
import { mergeProps } from '../_util/props-util';

const customCache = new Set();

export default function create(options) {
const { scriptUrl } = options;
const { scriptUrl, extraCommonProps = {} } = options;

/**
* DOM API required.
Expand Down Expand Up @@ -43,7 +44,8 @@ export default function create(options) {
if (children) {
content = children;
}
return <Icon {...{ ...data, props: restProps, on: listeners }}>{content}</Icon>;
const iconProps = mergeProps(extraCommonProps, data, { props: restProps, on: listeners });
return <Icon {...iconProps}>{content}</Icon>;
},
};
return Iconfont;
Expand Down
2 changes: 1 addition & 1 deletion components/icon/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The following options are available:
| Property | Description | Type | Default |
| --- | --- | --- | --- |
| scriptUrl | The URL generated by [iconfont.cn](http://iconfont.cn/) project. | string | - |
| extraCommonProps | Define extra properties to the component | `{ [key: string]: any }` | {} |
| extraCommonProps | Define extra properties to the component | `{ class, attrs, props, on, style }` | {} |

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

Expand Down
2 changes: 1 addition & 1 deletion components/icon/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ new Vue({
| 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- |
| scriptUrl | [iconfont.cn](http://iconfont.cn/) 项目在线生成的 `js` 地址 | string | - |
| extraCommonProps | 给所有的 `svg` 图标 `<Icon />` 组件设置额外的属性 | `{ [key: string]: any }` | {} |
| extraCommonProps | 给所有的 `svg` 图标 `<Icon />` 组件设置额外的属性 | `{ class, attrs, props, on, style }` | {} |

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

Expand Down

0 comments on commit 0a0a6a6

Please sign in to comment.