入力カーソル位置入力ボックスの問題

問題


ファジー検索が自動的に選択された後、カーソルは、入力に位置している端部に配置されます。

解きます

setTimeout(() => {
    let obj = this.$refs.custominput;
    let value = obj.value;
    if (document.selection) {
      var sel = obj.createTextRange();
      sel.moveStart('character', value.length);
      sel.collapse();
      sel.select();
    } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
        obj.selectionStart = obj.selectionEnd = value.length;
    }
}, 0);

次のような効果を解決した後です。

おすすめ

転載: www.cnblogs.com/xsnow/p/11818936.html