您好,欢迎访问一九零五行业门户网

资源合并与压缩的优化方法介绍

本篇文章给大家带来的内容是关于资源合并与压缩的优化方法介绍,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
要求
假定现在有路由/news,/login监听键盘事件,只允许在/news页面内有效不管后面跳到哪个页面,都不会触发对应的键盘事件,只能在/news里才触发
问题
没有进入/news之前,按键盘上的键,不会触发事件,进过/news后,不管有没有按键盘上的键,再跳到别的页面,按键盘上的键,都会触发事件
代码
srcviewsnews.vue
<template>  <div>    news  </div></template><script>export default {  data() {    return {      flag: true, //底部图片列表显示隐藏      name: aa    };  },  methods: {    keyleft() {      alert(this.name);    },    keyup() {      alert(向上方向键);    },    keyright() {      alert(向右方向键);    },    keydown() {      alert(向下方向键);    },    keys() {      var that = this;      document.onkeydown = function(e) {        let key = window.event.keycode;        if (key == 37) {          that.keyleft();        } else if (key == 38) {          that.keyup();          return false; //有上下滚动条的时候,不向上滚动        } else if (key == 39) {          that.keyright();        } else if (key == 40) {          that.keydown();          return false; //有上下滚动条的时候,不向上滚动        }      };    }  },  created() {    if (this.flag == true && this.$route.path == /news) {      this.keys();    }  },  mounted() {}};</script>
以上就是资源合并与压缩的优化方法介绍的详细内容。
其它类似信息

推荐信息