a1300399510@qq.com 提交于 2023/04/06 -14:20:02
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
<div class="search-input flexacenter">
|
||||
<div class="form flexacenter">
|
||||
<img class="search-icon" src="@/assets/img/headerNav/search.png">
|
||||
<input class="flex1" ref="searchInput" v-model="searchText" type="text" placeholder="请输入搜索关键词" />
|
||||
<input class="flex1" ref="searchInput" v-model="searchText" type="text" placeholder="请输入搜索关键词"
|
||||
@keydown.enter="toSearchResult(searchText)" />
|
||||
<img v-if="searchText" @click.stop="clearText()" class="clear-text" src="@/assets/img/icon/clear.png">
|
||||
</div>
|
||||
|
||||
@@ -45,13 +46,14 @@ export default {
|
||||
searchWinShow: false,//显示搜索弹窗
|
||||
searchText: '',
|
||||
showClear: false, //显示清除按钮
|
||||
historicalSearch: [], // 历史搜索
|
||||
historicalSearch: this.$store.state.historicalSearch, // 历史搜索
|
||||
}
|
||||
},
|
||||
props: ["issearch", "hotSearchkeywords"],
|
||||
|
||||
watch: {
|
||||
historicalSearch(val, oldval) {
|
||||
if (val.length > 10) this.historicalSearch.slice(0, 10)
|
||||
localStorage.setItem('historicalSearch', JSON.stringify(val));
|
||||
}
|
||||
},
|
||||
@@ -83,7 +85,12 @@ export default {
|
||||
|
||||
// 跳转搜索结果
|
||||
toSearchResult(kw) {
|
||||
|
||||
if (!kw) return
|
||||
this.historicalSearch.push(kw)
|
||||
|
||||
if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw)
|
||||
|
||||
this.$router.push(`/searchResult?kw=${kw}`)
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user