Nuxt picture problem

use: src= "item.url"
Why can"t you bind a picture in this way? it can only be written as static

.

or write

in data

data () {

return {
    item: {
        url: require("~/assets/img/home.png")
    }
}

}

Why would it not work to use direct: src= "item.url"?

Apr.11,2021

because you write it statically, it will be compiled by webpack to get the correct real path of the packaged image.
if you write dynamic, webpack will not compile, and put '~ / assets/img/home.png' in the src of your picture intact. Do you have this picture in https://img.codeshelper.com/upload/img/2021/04/11/gveaturhrqb16048.png?


put the picture in the static directory and change it to this

require('static/img/home.png')

the path where your url is'~ / assets/img/home.png', is not accessible under your server.

you can put this picture on cdn, or under a path that your server can access directly.


Hello. Did you ask this question?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e45abe-4388b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e45abe-4388b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?