[Vue] input textarea automatically scrolls to the input

Because here I want to return to the interface of the log continuously added to the textarea, like automatic scrolling log results.

1. First, a given type of input components textarea

    <el-input id="textarea_id"
            type="textarea"
              :rows="20"
            placeholder="请输入内容"
            v-model="textarea" readonly="">
    </el-input>

2. Every time new content should call

const textarea = document.getElementById('textarea_id');
textarea.scrollTop = textarea.scrollHeight;

 

Guess you like

Origin www.cnblogs.com/jxd283465/p/11640455.html