mounted(){
this.addEnterListener();
},
``
`
```javascript
methods:{
addEnterListener() {
if (window.__completeEnterBind__) return;
window.addEventListener("keydown", this.enterCallback);
window.__completeEnterBind__ = true;
},
removeEnterListener() {
window.removeEventListener("keydown", this.enterCallback);
window.__completeEnterBind__ = false;
},
enterCallback(e) {
function findFormItem(el) {
debugger
const parent = el.parentElement;
if (!parent) return document.body;
if (
parent.className.includes("el-form-item") &&
parent.className.includes("el-form-item--small")
) {
return parent;
}
return findFormItem(parent);
}
function findInput(container) {
debugger
let nextEl = container.nextElementSibling;
if (!nextEl){
var dialogSubmit = document.getElementById("dialogSubmit");
dialogSubmit.focus();
return;
}
let input = nextEl.querySelector("input");
while(input.disabled){
nextEl = nextEl.nextElementSibling;
input = nextEl.querySelector("input");
}
while (input.id === "el-select") {
nextEl = nextEl.nextElementSibling;
if (!nextEl) return;
input = nextEl.querySelector("input");
}
if (input.className.includes("el-input__inner")) return input;
if (input.className.includes("el-radio__original")) return input;
}
if (e.keyCode === 13) {
const container = findFormItem(document.activeElement);
findInput(container) && findInput(container).focus();
}
},
}
destroyed(){
this.removeEnterListener();
}