0
我正在学习vue
。我有以下方法在id="toolbar-chat"
上添加聊天消息到div。这个div允许在y轴上滚动,并且我希望div在每次添加新消息时都跳到顶部。为什么我的JS不工作?Vue方法滚动div顶部
document.getElementById("toolbar-chat").scrollTop = 0;
我vue
方法:
methods: {
addMessage(message) {
this.messages.unshift(message);
document.getElementById("toolbar-chat").scrollTop = 0;
axios.post(chat_send_route, message)
.then(response => {
console.log(response.data);
});
}
}