当我收到新消息或发送新消息时,聊天应该向下滚动。我用这个监视器来处理(我更新Vuex中的随机值,并观察聊天组件中的变化):
watch: {
scrollChatDown: function (val) {
if (this.$refs.chat !== undefined) {
this.$refs.chat.scrollTop = 9999999999999999999999
console.log('WORKING!')
}
}
}
我在Mozilla得到了这个console.log
,但是scrollTop
不工作,有没有其他的解决方案?:D
发布于 2019-08-16 04:27:39
看这个,使用当前高度向下滚动
watch: {
scrollChatDown: function (val) {
if (this.$refs.chat !== undefined) {
this.$refs.chat.scrollTop = this.$refs.chat.scrollHeight
console.log('WORKING!')
}
}
}
https://stackoverflow.com/questions/57515779
复制相似问题