Vue Image Skeleton
2022-07-29 금
Last updated
2022-07-29 금
Last updated
<template>
<img
:src="
isLoaded && src ? src : `${require('@/assets/images/' + defaultImage)}`
"
:alt="alt"
@load="onLoadImage"
/>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: {
src: {
type: String,
},
defaultImage: {
type: String,
default: "ico_default.png",
},
alt: {
type: String,
default: "",
},
},
data() {
return {
isLoaded: false,
};
},
methods: {
onLoadImage() {
this.isLoaded = true;
},
},
});
</script>
<style lang="scss" scoped>
img {
width: inherit;
height: inherit;
object-fit: cover;
}
</style><Img :src="srcUrl" defaultImage="ico_profile.png" />