update Avatar
This commit is contained in:
parent
c5a721ade8
commit
a1530fac5a
4 changed files with 116 additions and 7 deletions
|
@ -1,15 +1,38 @@
|
|||
<template>
|
||||
<span>
|
||||
|
||||
<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>
|
||||
import Icon from '../icon';
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-avatar';
|
||||
|
||||
export default {
|
||||
name: 'Avatar',
|
||||
components: { Icon },
|
||||
props: {
|
||||
|
||||
shape: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['circle', 'square']);
|
||||
},
|
||||
default: 'circle'
|
||||
},
|
||||
size: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['small', 'large', 'default']);
|
||||
},
|
||||
default: 'default'
|
||||
},
|
||||
src: {
|
||||
type: String
|
||||
},
|
||||
icon: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -17,7 +40,17 @@
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
|
||||
classes () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
`${prefixCls}-${this.shape}`,
|
||||
`${prefixCls}-${this.size}`,
|
||||
{
|
||||
[`${prefixCls}-image`]: !!this.src,
|
||||
[`${prefixCls}-icon`]: !!this.icon
|
||||
}
|
||||
];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue