fix: icon extraCommonProps not work #737

pull/833/head
tangjinzhou 6 years ago
parent 1704ce4282
commit 0a0a6a6103

@ -1,9 +1,10 @@
import Icon from './index'; import Icon from './index';
import { mergeProps } from '../_util/props-util';
const customCache = new Set(); const customCache = new Set();
export default function create(options) { export default function create(options) {
const { scriptUrl } = options; const { scriptUrl, extraCommonProps = {} } = options;
/** /**
* DOM API required. * DOM API required.
@ -43,7 +44,8 @@ export default function create(options) {
if (children) { if (children) {
content = 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; return Iconfont;

@ -72,7 +72,7 @@ The following options are available:
| Property | Description | Type | Default | | Property | Description | Type | Default |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| scriptUrl | The URL generated by [iconfont.cn](http://iconfont.cn/) project. | string | - | | 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. The property `scriptUrl` should be set to import the SVG sprite symbols.

@ -70,7 +70,7 @@ new Vue({
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| scriptUrl | [iconfont.cn](http://iconfont.cn/) 项目在线生成的 `js` 地址 | string | - | | 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/) 项目中的图标符号集,无需手动引入。 `scriptUrl` 都设置有效的情况下,组件在渲染前会自动引入 [iconfont.cn](http://iconfont.cn/) 项目中的图标符号集,无需手动引入。

Loading…
Cancel
Save