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

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);
  }
});
主站蜘蛛池模板: 浮梁县| 璧山县| 平定县| 灵寿县| 江陵县| 灌南县| 开江县| 阿拉尔市| 延津县| 灵台县| 昌江| 延川县| 芷江| 大同市| 台南县| 渭源县| 河曲县| 元朗区| 昭苏县| 沈阳市| 塘沽区| 丽江市| 灌阳县| 萨嘎县| 邛崃市| 枣庄市| 松江区| 辽宁省| 南涧| 垫江县| 建宁县| 澄城县| 七台河市| 三穗县| 呼玛县| 札达县| 高邑县| 福鼎市| 漳平市| 章丘市| 金阳县|