Skip to content

FaAvatar ​

Extends the native avatar with Base64 support and original, standard, small and thumbnail suffixes used by the Fast image service.

Avatar Modes

Interactive example
View code
Vue
<template>
	<div class="demo-row">
		<div class="demo-caption-item"><FaAvatar :src="avatar" original :size="64" /><span>原图</span></div>
		<div class="demo-caption-item"><FaAvatar :src="avatar" original shape="square" :size="64" /><span>方形</span></div>
		<div class="demo-caption-item"><FaAvatar :src="pixel" base64 :size="64">Base64</FaAvatar><span>Base64</span></div>
		<div class="demo-caption-item"><FaAvatar :size="64" /><span>默认图标</span></div>
	</div>
</template>

<script setup lang="ts">
const avatar = `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(
	'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120"><rect width="120" height="120" rx="24" fill="#409eff"/><text x="60" y="76" text-anchor="middle" font-size="34" fill="white">Fast</text></svg>'
)}`;
const pixel = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAusB9Wl2nzoAAAAASUVORK5CYII=";
</script>

FaAvatar Complete API

Props

EL defaults refer to Element Plus before Fast is imported. 2.14.7

PropertySourceDescriptionTypeDefault
iconFast overrideIcon component or name.String / Object / FunctionFast—EL—
srcFast overrideImage URL or Base64 content.StringFast""EL""
base64Fast additionInterpret the value as Base64 image content.Booleanfalse
originalFast additionUse the original image URL.Booleanfalse
normalFast additionUse the standard-image URL suffix.Booleanfalse
smallFast additionUse the small-image URL suffix.Booleanfalse
thumbFast additionUse the thumbnail URL suffix.Booleanfalse
sizeEL nativeComponent size.Number / String—
shapeEL nativeAvatar shape.String—
altEL nativeAlternative text when image loading fails.String—
srcSetEL nativeNative image srcset.String—
fitEL nativeHow content fits its container.Stringcover

Events

NameSourceDescriptionParameters / type
errorEL nativeResource loading or component processing fails.—

Slots

NameSourceDescriptionParameters / type
default({ src })EL nativeDefault component content.({ src })

Exposes

NameSourceDescriptionParameters / type
srcFast additionFinal processed FaAvatar image URL.—