I'm using Nuxt v3.0.0-rc.12
.
I have a component that needs to show an image, but the image path changes based on the image
prop:
<template>
<img alt="" :src="resolvedImage">
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
image: {
default: '',
type: String
}
})
const resolvedImage = computed(() => {
return props.image ? new URL(props.image, import.meta.url).href : ''
})
</script>
And I use this component like that:
<my-component image="../assets/somefolder/filename.png" />
I've read in the Vite docs that the correct way to do that is with new URL(url, import.meta.url)
. It works, but not in the first page load (because SSR).
I get this warning and the image is not displayed.
What am I doing wrong?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/H8QdEn7
Comments
Post a Comment