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

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);
  }
});
主站蜘蛛池模板: 葵青区| 元朗区| 德清县| 临湘市| 周宁县| 特克斯县| 泸定县| 城市| 忻城县| 阜城县| 华宁县| 岢岚县| 桃江县| 岫岩| 监利县| 西林县| 东乡县| 晋宁县| 轮台县| 达日县| 西安市| 平泉县| 张家界市| 吉安市| 新兴县| 宁乡县| 清远市| 德昌县| 理塘县| 兴安县| 汝州市| 聂荣县| 大新县| 抚顺市| 体育| 尼木县| 桑植县| 搜索| 昭通市| 招远市| 沿河|