On the problem of updating rendering of vue data Array

The

page loads, then gets the data from the background, and then binds it to the array in data with set. If you want to use the updated data in mounted, you can"t get it all the time, and it should be a problem of asynchronous loading, but you can"t solve it.

  //axios   created
    innerBase().then(res =>{
      this.$set(this.$data,"musicList",res.data.playlist.tracks)  
      //musicList
    })
data {
    return {
        musicList:""
    }
}
//mounted
     console.log(this.musicList)  // null
     this.playMusic(this.musicList[0]);
Mar.02,2021

because it is an asynchronous call, by the time your data arrives, the execution in mounted will be finished, so you can not get the data
you can put the methods in created into mounted to execute. After returning the data, you can perform other operations


the life cycle of vue is not fully understood. When the asynchronous operation has a response, mounted is finished. If you want to call it when data has data, You can use updated or beforeUpdate lifecycle hooks

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