在class為ipt1的input綁定focus事件,另外一個input也會觸發(fā)這個focus,請問如何銷毀?<el-input class="ipt1" type="textarea" @focus="focusIpt()"></el-input>
<el-input class="ipt2" type="textarea"></el-input><script>
focusIpt(){ let enterEvent = function(e){
... // do something
}
document.onkeydown = enterEvent
}
</script>
2 回答

寶慕林4294392
TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個贊
你監(jiān)聽事件的時候,寫成標(biāo)準(zhǔn)的
document.addEventListener('keydown', fun);document.removeEventListener('keydown', fun);//移除監(jiān)聽事件的回調(diào)函數(shù)
添加回答
舉報(bào)
0/150
提交
取消