fix: icon extraCommonProps not work #737

pull/833/head
tangjinzhou 2019-05-26 13:57:43 +08:00
parent 1704ce4282
commit 0a0a6a6103
3 changed files with 6 additions and 4 deletions

View File

@ -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.
@ -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;

View File

@ -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.

View File

@ -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/) 项目中的图标符号集,无需手动引入。