Avatar add custom-icon prop

This commit is contained in:
梁灏 2018-07-03 17:37:22 +08:00
parent acf00f5cc2
commit afafafce6e
2 changed files with 9 additions and 3 deletions

View file

@ -30,6 +30,8 @@
<Avatar shape="square" icon="ios-person" />
</Badge>
</div>
<br><br><br>
<Avatar custom-icon="ivu-icon-ios-person" />
</div>
</template>
<script>

View file

@ -1,7 +1,7 @@
<template>
<span :class="classes">
<img :src="src" v-if="src">
<Icon :type="icon" v-else-if="icon"></Icon>
<Icon :type="icon" :custom="customIcon" v-else-if="icon || customIcon"></Icon>
<span ref="children" :class="[prefixCls + '-string']" :style="childrenStyle" v-else><slot></slot></span>
</span>
</template>
@ -34,7 +34,11 @@
},
icon: {
type: String
}
},
customIcon: {
type: String,
default: ''
},
},
data () {
return {
@ -52,7 +56,7 @@
`${prefixCls}-${this.size}`,
{
[`${prefixCls}-image`]: !!this.src,
[`${prefixCls}-icon`]: !!this.icon
[`${prefixCls}-icon`]: !!this.icon || !!this.customIcon
}
];
},