JS之el-input 回车触发事件并且重新聚焦全选文本
el-input 回车触发事件并且重新聚焦全选文本
<el-input
style="width:140px;"
v-model="value"
@keyup.enter.native="enterInput"
@focus="getInputFocus($event)"
ref="toFoucus"
/>
———————————————————————
methods: {
enterInput() {
this.$refs.toFoucus.select() // 重新选择
this.$nextTick(() => {
this.$refs.toFoucus.focus();//输入框默认获取焦点
});
},
getInputFocus(event) {
event.currentTarget.select();
}
}
注:本文可分享可转发,转发请注明出自bug源