[improvement] declare functional sfc (#2695)

This commit is contained in:
neverland
2019-02-06 21:11:12 +08:00
committed by GitHub
parent 061382014d
commit 1b60e4df80
14 changed files with 465 additions and 494 deletions

View File

@@ -4,41 +4,40 @@ import isSrc from '../utils/validate/src';
const [sfc] = use('icon');
export default sfc(
{
props: {
name: String,
size: String,
color: String,
info: [String, Number],
classPrefix: {
type: String,
default: 'van-icon'
}
},
export default sfc({
functional: true,
render(h, context) {
const { props } = context;
const urlIcon = isSrc(props.name);
return (
<i
class={[
props.classPrefix,
urlIcon ? 'van-icon--image' : `${props.classPrefix}-${props.name}`
]}
style={{
color: props.color,
fontSize: props.size
}}
{...context.data}
>
{context.children}
{urlIcon && <img src={props.name} />}
<Info info={props.info} />
</i>
);
props: {
name: String,
size: String,
color: String,
info: [String, Number],
classPrefix: {
type: String,
default: 'van-icon'
}
},
true
);
render(h, context) {
const { props } = context;
const urlIcon = isSrc(props.name);
return (
<i
class={[
props.classPrefix,
urlIcon ? 'van-icon--image' : `${props.classPrefix}-${props.name}`
]}
style={{
color: props.color,
fontSize: props.size
}}
{...context.data}
>
{context.children}
{urlIcon && <img src={props.name} />}
<Info info={props.info} />
</i>
);
}
});