The background image that is dynamically added to the div after the resource is requested in vue, why can't it be displayed?

data(){
    return {
        bg:""
    }
}

the requested resource can be added to the bg, but the div has width and height even if it is not shown.

Feb.27,2021

The

code is fine. I think the picture should be out, but it's in the wrong position. You can try it like this

.
<div v-if="bg" :style="{'background':'url('+bg+')center center;'}"></div>

the width and height of bigBg are set in advance


looks normal, but you can console your url to see if the path is correct.


I return the link at the back end of uploading the image locally, and then add it to the background of div. There is nothing wrong with using backgroundImage. There may be a delay. When assigning to the background, adding a setTimeout, will work

.
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-1ea4e6b-4f1e2.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-1ea4e6b-4f1e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?