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)
},
结果:
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIyVGduV2YfNWawNyZuBnL1QTNlRjYkZmZlRWYmVGOiljMzQTN2UGMwYmM4YDMkR2Lc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)