Avatar.vue 371 B

1234567891011121314151617181920212223
  1. <template>
  2. <u-avatar size="40" :src="info.avatar" :text="text"></u-avatar>
  3. </template>
  4. <script>
  5. export default {
  6. name: 'Avatar',
  7. props: {
  8. info: {
  9. default: () => ({}),
  10. type: Object,
  11. },
  12. },
  13. computed: {
  14. text() {
  15. const { avatar, userName = '' } = this.info;
  16. return avatar ? undefined : userName.charAt(0);
  17. },
  18. },
  19. };
  20. </script>
  21. <style scoped></style>