input = nextEl.querySelector("input");
}
if (input.className.includes("el-input__inner")) return input;
}
if (e.keyCode === 13) {
const container = findFormItem(document.activeElement);
findInput(container) && findInput(container).focus();
}
}
}
然后在
mounted 中添加回车监听和在
destroy 中移除回车键听。
mounted() {
this.addEnterListener();
},
destroy() {
this.removeEnterListener();
},需要注意的是,项目是多标签页的形式,表单组件可能会被渲染多次,所以通过在 window 对象上添加一个
__completeEnterBind__ 字段来确保回车换行事件正确绑定。总结
以上所述是小编给大家介绍的Vue中实现回车键切换焦点的方法,希望对大家有所帮助,也非常感谢大家对软件开发网网站的支持!










