vue监听回车事件
<el-button type="primary" @click="login">登录</el-button>created() {this.keyupSubmit();},methods(){keyupSubmit() {document.onkeydown = (e) => {let _key = window.event.keyCode;//!this.clic
·
<el-button type="primary" @click="login">登录</el-button>
created() {
this.keyupSubmit();
},
methods(){
keyupSubmit() {
document.onkeydown = (e) => {
let _key = window.event.keyCode;
//!this.clickState是防止用户重复点击回车
if (_key === 13&&!this.clickState) {
this.login();
}
};
},
}
更多推荐
已为社区贡献2条内容
所有评论(0)