效果图:
使用type=”search " 会得到如下的效果。
(PC端的效果):
(手机端的效果):点击”搜索“的时候,可以进行查询。
去掉type=”search“ 默认带的x号:
input[type="search"]::-webkit-search-cancel-button {display: none;}
敲手机上的 ”回车“,”搜索“等搜索按钮的时候,会触发搜索。
<input type="search" placeholder="搜索2" v-model="searchContext" @keypress="searchInputConHandler" />
searchInputConHandler: function() {that = this;console.log('文本输入框被触发了');var keycode = event.keyCode;//获取搜索框的值var searchContent = that.searchContext;if (keycode == '13') {event.preventDefault();if (searchContent == '') {console.log('请输入搜索内容');} else {that.toSearch();}}}
-------完。