<form action="javascript:return true"> <!-- form ios手机上唤起搜索按钮(默认是换行按钮) --> <input @keypress="searchBtn" type="search" name="" id="" value="" placeholder="医生" v-model="put" /> </form> searchBtn(event) { if (event.keyCode == 13) { //如果按的是enter键 13是enter event.preventDefault(); //禁止默认事件(默认是换行) console.log(event.target.value) var search_val = event.target.value; if(search_val == ''||search_val==null){ alert('搜索内容不能为空'); }else{ this.$router.push({path: '/doctorlist?keywords=' + search_val}); } } }