天天看点

vue 中 created 与mounted先后执行问题

mounted先执行再是created

代码:

created() {
    this.request.get("/jk/fs",{
    }).then( res =>{
      console.log("created")
      this.totalfs = res.data
    })
    this.$emit('mount')
  },
  mounted() { //页面元素渲染后再触发
    console.log("mounted",this.totalfs)
    // this.$on('mount',()=>{
    //   console.log("第2次",this.totalfs)
    // })
    // console.log("第三次",this.totalfs)
  },
           

结果:

vue 中 created 与mounted先后执行问题

继续阅读