亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

div上的ScrollTop,Vuejs

div上的ScrollTop,Vuejs

瀟湘沐 2022-07-21 09:48:20
我有一個帶有文本的 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);  }}  
查看完整描述

2 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

scrollTop 函數是窗口對象或元素本身的一部分

在您的情況下,它將是:

topElement.scrollTo (100,0)

文檔:https ://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo


查看完整回答
反對 回復 2022-07-21
?
小唯快跑啊

TA貢獻1863條經驗 獲得超2個贊

var topElement =  document.querySelector('.question-editor');
    topElement.scrollIntoView(true);

為了更清楚文檔:https ://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView


查看完整回答
反對 回復 2022-07-21
  • 2 回答
  • 0 關注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號