mounted(){
// 添加键盘Esc事件
this.$nextTick(()=>{
document.addEventListener('keyup',(e)=>{
if(e.keyCode==27){
this.changeMethodf() //事件名
}
})
}),
}
如果不用箭头函数的话,需要在外面把this赋给一个值然后在事件中使用
mounted(){
let that=this
// 添加键盘Esc事件
this.$nextTick(function(){
document.addEventListener('keyup',function(e){
if(e.keyCode==27){
that.changeMethodf() //事件名
}
})
}),
}