、スクロール可能なdivが実際に.chat-content
の代わり.chat-body
です。
正しいdivのスクロール位置を確認する必要があります。後世のために、あなたはmounted()
時に実行されるメソッドを追加することができます。
ここ
new Vue({
el: '#app',
data: {...},
mounted() {
this.stubMessages();
this.setScrollPos();
this.watchScroll();
},
methods: {
setScrollPos(){
var cBody = document.querySelector('.chat-content');
cBody.scrollTop = 99999999; // arbitrary/calculated value to get to the end of the div
},
watchScroll() {
var cBody = document.querySelector('.chat-content');
// watch scroll position of content area
cBody.addEventListener('scroll', function(){
console.log('scroll', cBody.scrollTop);
});
},
stubMessages() {...},
addMessage() {...}
}
});