How to make <img > render after ajax gets the data (including src) in vue

The

diagram can be displayed. Since the binding value of : src does not exist at the beginning of ajax asynchronism, it will be reported

.
Cannot read property "avatar" of null"

when ajax comes back, the picture will come out

what should I do with this

Mar.05,2021

you first leave the position of the picture blank or put the default picture (the popular point is, write a div to set the height and width, put the picture in the div, and do not display the picture at first)

then define a variable flag, in data that controls picture display with an initial value of false

After

ajax gets the value, change the value of the variable just defined to true

finally, the display is controlled on the img by using the 'vmurshowrooms'.

if the impact of the large image will affect the interface, it is recommended to directly give the entire interface a loading, to obtain the value before displaying the interface.

the small image would be fine with the above method


judge: src= "item & & item.avatar"

Menu