erp-el-element/utils/directive.js

22 lines
705 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Vue from 'vue';
// 自定义指令实现按下enter后光标自动跳转下一个输入框
Vue.directive('enterNextInput', {
inserted: function (el) {
el.addEventListener("keypress",function(e){
e = e || window.event;
let charcode = typeof e.charCode == 'number' ? e.charCode : e.keyCode;
if(charcode == 13){
var dom = document.querySelectorAll(".el-input__inner")
for (var i = 0; i < dom.length; i++) {
if (dom[i] == document.activeElement) {
if (i==dom.length) {
return
}
dom[i+1].focus()
return
}
}
}
});
},
});