Commit afafafce6e741ff93cff9f6a91bb8cab95320e7b

Authored by 梁灏
1 parent acf00f5c

Avatar add custom-icon prop

examples/routers/avatar.vue
@@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
30 <Avatar shape="square" icon="ios-person" /> 30 <Avatar shape="square" icon="ios-person" />
31 </Badge> 31 </Badge>
32 </div> 32 </div>
  33 + <br><br><br>
  34 + <Avatar custom-icon="ivu-icon-ios-person" />
33 </div> 35 </div>
34 </template> 36 </template>
35 <script> 37 <script>
src/components/avatar/avatar.vue
1 <template> 1 <template>
2 <span :class="classes"> 2 <span :class="classes">
3 <img :src="src" v-if="src"> 3 <img :src="src" v-if="src">
4 - <Icon :type="icon" v-else-if="icon"></Icon> 4 + <Icon :type="icon" :custom="customIcon" v-else-if="icon || customIcon"></Icon>
5 <span ref="children" :class="[prefixCls + '-string']" :style="childrenStyle" v-else><slot></slot></span> 5 <span ref="children" :class="[prefixCls + '-string']" :style="childrenStyle" v-else><slot></slot></span>
6 </span> 6 </span>
7 </template> 7 </template>
@@ -34,7 +34,11 @@ @@ -34,7 +34,11 @@
34 }, 34 },
35 icon: { 35 icon: {
36 type: String 36 type: String
37 - } 37 + },
  38 + customIcon: {
  39 + type: String,
  40 + default: ''
  41 + },
38 }, 42 },
39 data () { 43 data () {
40 return { 44 return {
@@ -52,7 +56,7 @@ @@ -52,7 +56,7 @@
52 `${prefixCls}-${this.size}`, 56 `${prefixCls}-${this.size}`,
53 { 57 {
54 [`${prefixCls}-image`]: !!this.src, 58 [`${prefixCls}-image`]: !!this.src,
55 - [`${prefixCls}-icon`]: !!this.icon 59 + [`${prefixCls}-icon`]: !!this.icon || !!this.customIcon
56 } 60 }
57 ]; 61 ];
58 }, 62 },