官术网_书友最值得收藏!

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);
  }
});
主站蜘蛛池模板: 龙门县| 西乌| 彰化县| 兴业县| 林甸县| 彰武县| 云林县| 灵宝市| 湟源县| 南乐县| 定襄县| 永顺县| 锡林郭勒盟| 枣强县| 漳州市| 印江| 郸城县| 迭部县| 南汇区| 达孜县| 弋阳县| 富顺县| 湘乡市| 景德镇市| 沅陵县| 崇信县| 肃南| 清涧县| 黔西| 三原县| 济源市| 如东县| 乌审旗| 三河市| 襄汾县| 曲水县| 郯城县| 云和县| 沙坪坝区| 丹巴县| 咸宁市|