overflow: the scroll component automatically scrolls to the bottom of the element after adding content

When an element sets overflow:scroll, the excess part needs to be scrolled to view. When the content increases, it is better to scroll to the bottom for a better experience.

<el-input
        :autosize="{ minRows: 20, maxRows: 26 }"
        type="textarea"
        class="inputText"
        id="mainText"
        v-model="articleText"
        resize="none"
        placeholder="请输入文章内容"
      ></el-input>
this.$nextTick(() => {
    
    
      setTimeout(() => {
    
    
        const textarea = document.getElementById('mainText');
        if (textarea) {
    
    
          textarea.scrollTop = textarea.scrollHeight;
        }
      }, 10);
    });

Guess you like

Origin blog.csdn.net/qq_41867900/article/details/130602589