vue的input标签:
<input type="search" class="weui-search-bar__input" v-bind:placeholder="isQueryByLike?'模糊搜索':'精准搜索'" ref="search">
vue对enter键的监听:
created:function(){
var that=this;
document.onkeydown=function(e){
var key=window.event.keyCode;
if(key==13){
that.getCode();
}
}
},
vue对事件处理的method:
methods: {
getCode: function (event) {
this.$refs.search.blur();
<!--上面这句话就是最后的处理办法,让input标签失去焦点,具体的原理不懂-->
var bindphone = this.$refs.search.value;
if(""==bindphone) {
this.showErrMessage("请输入搜索条件");
return;
}
var url = getCodeUrl + '?bindphone=' + bindphone + '&choice=' + choice;
<!--url后面的getcodeurl这个是在资源文件里面写的,es6吧!,后来导入-->
this.$http.get(url,{ emulateJSON : true,withCredentials: true }).then(function(res){
console.log(res.body);
console.log(res.body.data);
if(res.body.code == 1){
.....
}else{
.....
}
},function(){
console.log('请求失败处理');
});
},
处理办法:
this.$refs.search.blur();
通过这个,对input的标签焦点处理!具体的原理不是很清晰,只是知道处理办法