//官方
mounted: function () {
this.$nextTick(function () {
// Code that will run only after the
// entire view has been rendered
})
}
//或者 浏览器17ms刷新一次,20ms后再运行
mounted: function () {
setTimeout(()=>{
// Code that will run only after the
// entire view has been rendered
},20)
}
有时候请求还未完成,就已经渲染完成,触发mounted。这时可以为页面中的元素加上v-if,当获得回掉数据时再渲染,触发mounted