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() //事件名
}
})
}),
}
