因为我用vue修饰符绑定键盘事件报错,不知道怎么解决...于是想出了一个神奇的解决方案...1.绑定输入事件,保存输入内容每次输入到本地存储//输入搜索内容inputSearchInfo(){localStorage.setItem('searchInput',this.searchInput);//保存在本地}2.使用jQuery键盘事件解析importmyVuefrom'../main.js'$(document).ready(function(){//判断是否是搜索框有焦点varsearchInpuIsFocus=false;$('.nav.nav-searchinput').focus(function(){searchInpuIsFocus=true;})$('.nav.nav-searchinput').blur(function(){searchInpuIsFocus=false;})//监听键盘事件$(document).keydown(function(event){varsearchInfo=localStorage.getItem('searchInput').trim();//本地检索//按下回车,input不为空,搜索跳转到c时的路由ontent与上次不同if(event.keyCode===13&&searchInfo!=''&&myVue.$route.params.value!=searchInfo){myVue.$router.push({path:'/search/'+搜索信息});//跳转到搜索结果页}//回车,输入为空,搜索框获得焦点时弹出错误提示elseif(event.keyCode===13&&searchInfo==''&&searchInpuIsFocus){myVue.$message({showClose:true,message:'搜索内容不能为空!',type:'error'});}});})