设置全局键盘事件,在哪个页面使用就写
ctrl+ent
methods: {
submit: function () {
alert("监听到ctrl + enter键");
},
},
created() {
var _this = this;
document.onkeydown = function (e) {
let key = window.event.keyCode;
if (key == 13 && event.ctrlKey) {
_this.submit();
}
};
},