feat(Avatar): add as prop to use NuxtImg underneath

Resolves #1577
This commit is contained in:
Benjamin Canac
2024-03-28 11:04:17 +01:00
parent bd8b737642
commit 49b73aa024

View File

@@ -1,13 +1,14 @@
<template>
<span :class="wrapperClass">
<img
<component
:is="as"
v-if="url && !error"
:class="imgClass"
:alt="alt"
:src="url"
v-bind="attrs"
@error="onError"
>
/>
<span v-else-if="text" :class="ui.text">{{ text }}</span>
<UIcon v-else-if="icon" :name="icon" :class="iconClass" />
<span v-else-if="placeholder" :class="ui.placeholder">{{ placeholder }}</span>
@@ -39,6 +40,10 @@ export default defineComponent({
},
inheritAttrs: false,
props: {
as: {
type: [String, Object],
default: 'img'
},
src: {
type: [String, Boolean],
default: null