- Full-Stack Vue.js 2 and Laravel 5
- Anthony Gore
- 61字
- 2021-07-02 19:57:24
Removing listener
To avoid any memory leaks, we should also useremoveEventListenerto get rid of the listener when the Vue instance is torn down. We can use thedestroyhook and call ourescapeKeyListenermethod for this purpose.
app.js:
new Vue({ data: { ... }, methods: { ... }, watch: { ... }, created: function() { ... }, destroyed: function () { document.removeEventListener('keyup', this.escapeKeyListener); } });
推薦閱讀
- Web程序設(shè)計(jì)及應(yīng)用
- Java語言程序設(shè)計(jì)
- 大學(xué)計(jì)算機(jī)基礎(chǔ)(第三版)
- Java異步編程實(shí)戰(zhàn)
- LabVIEW2018中文版 虛擬儀器程序設(shè)計(jì)自學(xué)手冊(cè)
- 算法精粹:經(jīng)典計(jì)算機(jī)科學(xué)問題的Python實(shí)現(xiàn)
- jQuery炫酷應(yīng)用實(shí)例集錦
- Android項(xiàng)目實(shí)戰(zhàn):手機(jī)安全衛(wèi)士開發(fā)案例解析
- 深入實(shí)踐Kotlin元編程
- 從零學(xué)Java設(shè)計(jì)模式
- 多媒體技術(shù)及應(yīng)用
- Mastering SciPy
- 從零開始構(gòu)建深度前饋神經(jīng)網(wǎng)絡(luò):Python+TensorFlow 2.x
- MongoDB Cookbook
- JBoss AS 7 Development