a1300399510@qq.com 提交于 2023/04/06 -16:00:01
This commit is contained in:
parent
bed54e917e
commit
44554dfceb
@ -53,9 +53,8 @@ export default {
|
||||
|
||||
watch: {
|
||||
historicalSearch(val, oldval) {
|
||||
console.log("val", val);
|
||||
if (val.length > 10) this.historicalSearch.slice(0, 10)
|
||||
this.$store.commit('setHistoricalSearch', val)
|
||||
else this.$store.commit('setHistoricalSearch', val)
|
||||
}
|
||||
},
|
||||
|
||||
@ -88,8 +87,8 @@ export default {
|
||||
toSearchResult(kw) {
|
||||
|
||||
if (!kw) return
|
||||
this.historicalSearch.push(kw)
|
||||
|
||||
console.log(this.historicalSearch);
|
||||
if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw)
|
||||
|
||||
this.$router.push(`/searchResult?kw=${kw}`)
|
||||
|
@ -11,12 +11,10 @@ export default new Vuex.Store({
|
||||
},
|
||||
mutations: {
|
||||
setHistoricalSearch(state, payload) {
|
||||
console.log(payload, "payload");
|
||||
payload = [...new Set(payload)]
|
||||
state.historicalSearch = payload
|
||||
|
||||
localStorage.setItem('historicalSearch', JSON.stringify(payload));
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
@ -15,7 +15,7 @@
|
||||
<!-- 结果数量 -->
|
||||
<div class="numberResults flexacenter">大约找到 <div class="number">{{ count }}</div> 条结果</div>
|
||||
<div class="result-box flexacenter" v-if="list.length != 0 || loading">
|
||||
<div class="result-item flexflex" v-for="(item, index) in list" :key="index">
|
||||
<div class="result-item flexflex" v-for="(item, index) in list" :key="index" @click.stop="toDetail(item.tid)">
|
||||
<div class="result-header one-line">
|
||||
<div class="result-label">{{ item.forum }}</div>
|
||||
<div class="result-title" v-html="item.subject"></div>
|
||||
@ -95,8 +95,11 @@ export default {
|
||||
},
|
||||
|
||||
historicalSearch(val, oldval) {
|
||||
if (val.length > 10) this.historicalSearch.slice(0, 10)
|
||||
this.$store.commit('setHistoricalSearch', val)
|
||||
console.log("val", val);
|
||||
if (val.length > 10) this.historicalSearch = val.slice(0, 10)
|
||||
else this.$store.commit('setHistoricalSearch', val)
|
||||
|
||||
return val
|
||||
},
|
||||
},
|
||||
|
||||
@ -111,7 +114,8 @@ export default {
|
||||
handleSearchResult() {
|
||||
let kw = this.kw
|
||||
// this.historicalSearch.push(kw)
|
||||
if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw)
|
||||
console.log("this.historicalSearch", this.historicalSearch);
|
||||
if (!this.historicalSearch.includes(kw)) this.historicalSearch = this.historicalSearch.unshift(kw)
|
||||
|
||||
this.getSearchResult()
|
||||
},
|
||||
@ -147,7 +151,10 @@ export default {
|
||||
this.getSearchResult()
|
||||
},
|
||||
|
||||
|
||||
// 跳转详情
|
||||
toDetail(tid) {
|
||||
this.$router.push(`/detailIndex?tid=${tid}`)
|
||||
},
|
||||
|
||||
// 点击清空 input 的值
|
||||
emptyKw() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user