No data can be obtained in vue mounted

problem description

mounted
 console.log(this) 


vue

the environmental background of the problems and what methods you have tried

imageSrc createdapi 
vuex
computed 

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

 mounted  
May.16,2022

When

console.log (this) , in fact, imageSrc does not necessarily have
, but later if the api request is completed. Opening it in devTools displays the latest obj . So you can see that this has imageSrc

.

use computed and watch to execute. Obtained asynchronously in create . There is no guarantee that it must be before mounted


created is synchronized to mounted and will certainly be executed earlier than api .
wait for the API to be adjusted before taking a value, or watch

Menu