add enter key code

This commit is contained in:
Captain.B 2020-02-11 11:19:31 +08:00
parent eb9767c2d1
commit f51ddf2039
1 changed files with 17 additions and 0 deletions

View File

@ -81,7 +81,24 @@
} }
}); });
}, },
created: function () {
// ,,
document.addEventListener("keydown", this.watchEnter);
},
destroyed() {
//
document.removeEventListener("keydown", this.watchEnter);
},
methods: { methods: {
//
watchEnter(e) {
let keyNum = e.which; //
//keycody=13
if (keyNum === 13) {
//
this.submit('form');
}
},
submit(form) { submit(form) {
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (valid) { if (valid) {