38 lines
1.0 KiB
Vue
38 lines
1.0 KiB
Vue
<script setup lang="ts">
|
|
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
|
import { defineComponent, h } from "vue";
|
|
|
|
const SRC =
|
|
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg";
|
|
|
|
/** Stand-in for a framework image component (e.g. Next.js Image). */
|
|
const FrameworkImage = defineComponent({
|
|
name: "FrameworkImage",
|
|
inheritAttrs: false,
|
|
props: {
|
|
src: { type: String, required: true },
|
|
alt: { type: String, default: "" },
|
|
width: { type: [Number, String], default: 40 },
|
|
height: { type: [Number, String], default: 40 },
|
|
},
|
|
setup(props, { attrs }) {
|
|
return () =>
|
|
h("img", {
|
|
...attrs,
|
|
src: props.src,
|
|
alt: props.alt,
|
|
width: props.width,
|
|
height: props.height,
|
|
});
|
|
},
|
|
});
|
|
</script>
|
|
<template>
|
|
<Avatar>
|
|
<AvatarImage :src="SRC" as-child>
|
|
<FrameworkImage :src="SRC" alt="约翰·多伊" :width="40" :height="40" />
|
|
</AvatarImage>
|
|
<AvatarFallback>JD</AvatarFallback>
|
|
</Avatar>
|
|
</template>
|