input框无法随着输入自动的变长,可以利用div contentEditable模拟input框来实现
div模拟的输入框在focus的时候会有些问题
聚焦的位置在最前面,而不是在最后面,解决办法
const target = itemRef.value;
target.contentEditable = 'true';
target.focus();
// 关键点
const range = window.getSelection();
range.selectAllChildren(target);
range.collapseToEnd();