有以下代码,获取input焦点时将光标置在右侧的,现在项目有很多地方需要用上,请问怎么快速、简单的修改
@focus="inputFocusRight($event)"
inputFocusRight(e) {
const editTask = e.srcElement;
const length = editTask.value.length;
editTask.focus();
setTimeout(() => {
editTask.selectionStart = length;
editTask.selectionEnd = length;
});
},
全局自定义指令:
在组件里:
或者插件: