vue判断页面元素(图片、音频等)已经全部加载完毕后的事件
export default {
data () {
return {
timer: null, // 定时器
}
}
}
mounted () {
const that = this
that.timer = setInterval(function () {
console.log(document.readyState)
if (document.readyState === 'complete') {
that._scrollToBottom() // 将聊天框滚轮拉到最底部
window.clearInterval(that.timer)
}
}, 1000)
},
上述代码应用场景,---h5聊天页,由于created的时候只是页面元素的节点加载进来了,图片、音频等资源还未加载完全,导致滚轮无法拉至最底部
this.$nextTick 也不起作用