A
A
Alexander2021-05-30 18:06:17
Vue.js
Alexander, 2021-05-30 18:06:17

Images from the static folder are not shown. What could be the reason?

I'm starting to learn naxt and ran into a problem when images are not shown.
In the default.vue template I write a simple code:

<template>
  <div>
    <image src="images/logo.png"/>
    <Nuxt />
  </div>
</template>

The image is in the static/images folder.
And when it starts on localhost:3000, it throws errors:
60b3a79ceaeda678495209.png
[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside , or missing . Bailing hydration and performing full client-side render.

Moreover, the picture is visible in the inspector and when viewing the code, and it also opens by a link from the code.

I tried wrapping the image in <client-only></client-only>. The error disappears, but the image is not visible on the page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2021-05-30
@gdX

I'm stupid, I spelled the tag of the picture incorrectly.
That works correctly
<img src="/images/logo.png" alt="">

Y
Yuri, 2021-05-30
@cheeroque

Change the path to the image to absolute, from the root:
/images/logo.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question