primevue-mirror/components/lib/avatar/Avatar.vue

26 lines
827 B
Vue
Raw Normal View History

2022-09-06 12:03:37 +00:00
<template>
2023-05-29 09:19:55 +00:00
<div :class="cx('root')" :aria-labelledby="ariaLabelledby" :aria-label="ariaLabel" v-bind="ptm('root')" data-pc-name="avatar">
2023-04-27 12:18:17 +00:00
<slot>
<span v-if="label" :class="cx('label')" v-bind="ptm('label')">{{ label }}</span>
<component v-else-if="$slots.icon" :is="$slots.icon" :class="cx('icon')" v-bind="ptm('icon')" />
2023-05-25 14:41:58 +00:00
<span v-else-if="icon" :class="[cx('icon'), icon]" v-bind="ptm('icon')" />
<img v-else-if="image" :src="image" :alt="ariaLabel" @error="onError" v-bind="ptm('image')" />
2023-04-27 12:18:17 +00:00
</slot>
2022-09-06 12:03:37 +00:00
</div>
</template>
<script>
import BaseAvatar from './BaseAvatar.vue';
2022-09-06 12:03:37 +00:00
export default {
name: 'Avatar',
2023-05-23 13:16:38 +00:00
extends: BaseAvatar,
2022-09-14 11:26:01 +00:00
emits: ['error'],
2022-09-06 12:03:37 +00:00
methods: {
onError() {
this.$emit('error');
}
}
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
</script>