update Avatar
This commit is contained in:
parent
a1530fac5a
commit
ececc3bb4c
1 changed files with 23 additions and 14 deletions
|
@ -1,10 +1,3 @@
|
||||||
<template>
|
|
||||||
<span :class="classes">
|
|
||||||
<img :src="src" v-if="src">
|
|
||||||
<span :class="[prefixCls + '-string']" v-else-if="$slots.default"><slot></slot></span>
|
|
||||||
<Icon :type="icon" v-else-if="icon"></Icon>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<script>
|
<script>
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import { oneOf } from '../../utils/assist';
|
import { oneOf } from '../../utils/assist';
|
||||||
|
@ -13,7 +6,6 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Avatar',
|
name: 'Avatar',
|
||||||
components: { Icon },
|
|
||||||
props: {
|
props: {
|
||||||
shape: {
|
shape: {
|
||||||
validator (value) {
|
validator (value) {
|
||||||
|
@ -34,11 +26,6 @@
|
||||||
type: String
|
type: String
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
prefixCls: prefixCls
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
return [
|
return [
|
||||||
|
@ -52,8 +39,30 @@
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
render (h) {
|
||||||
|
let innerNode = '';
|
||||||
|
|
||||||
|
if (this.src) {
|
||||||
|
innerNode = h('img', {
|
||||||
|
attrs: {
|
||||||
|
src: this.src
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (this.icon) {
|
||||||
|
innerNode = h(Icon, {
|
||||||
|
props: {
|
||||||
|
type: this.icon
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (this.$slots.default) {
|
||||||
|
innerNode = h('span', {
|
||||||
|
'class': `${prefixCls}-string`
|
||||||
|
}, this.$slots.default);
|
||||||
|
}
|
||||||
|
|
||||||
|
return h('span', {
|
||||||
|
'class': this.classes
|
||||||
|
}, [innerNode]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
Loading…
Add table
Reference in a new issue