a1300399510@qq.com 提交于 2023/04/06 -12:40:02
This commit is contained in:
parent
d7807870c5
commit
e65241785b
@ -21,7 +21,8 @@
|
||||
<div class="search-content flexcolumn" v-if="historicalSearch.length != 0">
|
||||
<div class="search-text">历史搜索</div>
|
||||
<div class="search-label">
|
||||
<span v-for="(item, index) in historicalSearch" :key="index">香港大学</span>
|
||||
<span v-for="(item, index) in historicalSearch" :key="index" @click.stop="toSearchResult(item)">{{ item
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 热门搜索 -->
|
||||
@ -49,11 +50,10 @@ export default {
|
||||
},
|
||||
props: ["issearch", "hotSearchkeywords"],
|
||||
|
||||
mounted() {
|
||||
let hotSearchkeywords = ["香港大学","香港大学"]
|
||||
var cachedData = localStorage.setItem('hotSearchkeywords',[]) || [];
|
||||
|
||||
// var cachedData = localStorage.getItem('hotSearchkeywords') || [];
|
||||
watch: {
|
||||
historicalSearch(val, oldval) {
|
||||
localStorage.setItem('historicalSearch', JSON.stringify(val));
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
@ -83,6 +83,7 @@ export default {
|
||||
|
||||
// 跳转搜索结果
|
||||
toSearchResult(kw) {
|
||||
this.historicalSearch.push(kw)
|
||||
this.$router.push(`/searchResult?kw=${kw}`)
|
||||
},
|
||||
},
|
||||
@ -90,6 +91,13 @@ export default {
|
||||
if (this.searchText.length > 0) this.showClear = true
|
||||
else this.showClear = false
|
||||
|
||||
|
||||
// let hotSearchkeywords = ["香港大学", "香港大学"]
|
||||
// console.log(JSON.stringify(hotSearchkeywords));
|
||||
|
||||
this.historicalSearch = JSON.parse(localStorage.getItem('historicalSearch')) || []
|
||||
console.log(this.historicalSearch);
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user