Administrator 4 years ago
parent
commit
6c75b19018
1 changed files with 11 additions and 1 deletions
  1. 11 1
      pages/search/search-second.vue

+ 11 - 1
pages/search/search-second.vue

@@ -3,7 +3,7 @@
 		<view class="search-main">
 			<view class="gosearch-btn">
 				<text class="iconfont icon-sousuo"></text>
-				<input class="input" maxlength="20" type="text" value="" confirm-type="search" @confirm="subMitSearch()" placeholder="请输入关键词" v-model.trim="name"/>
+				<input class="input" maxlength="20" type="text" value="" confirm-type="search" @input="onShowClose" @focus="onFocus"  @confirm="subMitSearch()" placeholder="请输入关键词" v-model.trim="name"/>
 				<text class="iconfont icon-shanchu1" v-if="isShowClose" @click.stop="delInputText()"></text>
 			</view>
 		</view>
@@ -163,6 +163,16 @@
 					this.$util.msg(error.msg,2000);
 				})
 			},
+			onShowClose () {//输入框失去焦点时触发
+				if(this.name != ''){
+					this.isShowClose = true;
+				}else{					
+					this.isShowClose = false
+				}
+			},
+			onFocus () { //输入框获取焦点时触发
+				this.inputEmpty(this.searchInputVal)
+			},
 			delInputText () { //清除输入框内容
 				this.name = ''
 				this.isShowClose = false