< template >
<div>
<userDetail v-if="userdetailShow"></userDetail>
<el-button @click="detailShow"></el-button>
</div>
< / template >
data () {
return{
userdetailShow:false
}
}
created () {
this.keyupSubmit()
},
methods: {
/ / listen for carriage return events
keyupSubmit(){
document.onkeydown=e=>{
let _key=window.event.keyCode;
if(_key===13){
this.adduser()
}
}
},
detailShow(){
this.userdetailShow=true
}
}
there is a definite button button in the userdetai component, which listens to the carriage return event code in the userdetail component, and globally binds the method adduser () {/ p > in the carriage return event component.
this.userdetailShow=false
}
the enter event binding succeeded, but the display property of userdetail, the dailog component v-if binding, changes from true to false to true after the enter event.
according to the requirements and the logic of the code, the functions bound by the carriage return event are all run, but I don"t know why the thsi.userdetailShow=false has become true
.but if the dailog component pops up, if you click dailog and give the dailog focus, this situation will not happen
ask what the reason is.