我有一个带有文本的 div,提交该文本后,我从服务器获取新数据。如果我位于第一个文本的底部,那么我从服务器获取的第二个文本也在底部,并且我想在获取数据后移至文本的顶部。
<b-row class="question-top mb-3" >
<b-col xl="12" md="12" sm="12" xs="12">
<div class="question-editor">
<ckeditor :editor="editor" v-model="free_text" :disabled="editorDisabled"></ckeditor>
</div>
</b-col>
</b-row>
//style
.question-editor{
overflow-y: auto; //so here I have the scroll
}
methods(){
getData() {
axios...CODE..
//and here I try to move to the top of that div
var topElement = document.querySelector('.question-editor');
scrollTo(topElement, 0, 100);
}
}
最佳答案
scrollTop 函数是窗口对象或元素本身的一部分
在你的情况下,它是:
topElement.scrollTo (100,0)
文档:https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
关于javascript - div 上的 ScrollTop,Vuejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61479937/