Failed to save value in mounted phase of nuxt

 mounted(){
  let date = new Date();
  this.year = date.getFullYear().toString();
  console.log(this.year) //2018
  console.log(this) //year 
 }
 

clipboard.png
ask for help, is it true that data cannot be written in the mounted stage in data modified by nuxt

Nov.02,2021

Lou Zhu, hello ~
nuxt has only beforeCreate and created . You can use the asyncData method to get or process data asynchronously before setting the component's data. You can refer to this article, Portal


is not the problem of output sequence, in fact, you are a successful assignment
.
Menu