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" /> <Avatar shape="square" icon="ios-person" />
</Badge> </Badge>
</div> </div>
<br><br><br>
<Avatar custom-icon="ivu-icon-ios-person" />
</div> </div>
</template> </template>
<script> <script>

View file

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