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: {
|
watch: {
|
||||||
historicalSearch(val, oldval) {
|
historicalSearch(val, oldval) {
|
||||||
console.log("val", val);
|
|
||||||
if (val.length > 10) this.historicalSearch.slice(0, 10)
|
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) {
|
toSearchResult(kw) {
|
||||||
|
|
||||||
if (!kw) return
|
if (!kw) return
|
||||||
this.historicalSearch.push(kw)
|
|
||||||
|
|
||||||
|
console.log(this.historicalSearch);
|
||||||
if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw)
|
if (!this.historicalSearch.includes(kw)) this.historicalSearch.unshift(kw)
|
||||||
|
|
||||||
this.$router.push(`/searchResult?kw=${kw}`)
|
this.$router.push(`/searchResult?kw=${kw}`)
|
||||||
|
@ -11,12 +11,10 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
setHistoricalSearch(state, payload) {
|
setHistoricalSearch(state, payload) {
|
||||||
|
console.log(payload, "payload");
|
||||||
payload = [...new Set(payload)]
|
payload = [...new Set(payload)]
|
||||||
state.historicalSearch = payload
|
state.historicalSearch = payload
|
||||||
|
|
||||||
localStorage.setItem('historicalSearch', JSON.stringify(payload));
|
localStorage.setItem('historicalSearch', JSON.stringify(payload));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<!-- 结果数量 -->
|
<!-- 结果数量 -->
|
||||||
<div class="numberResults flexacenter">大约找到 <div class="number">{{ count }}</div> 条结果</div>
|
<div class="numberResults flexacenter">大约找到 <div class="number">{{ count }}</div> 条结果</div>
|
||||||
<div class="result-box flexacenter" v-if="list.length != 0 || loading">
|
<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-header one-line">
|
||||||
<div class="result-label">{{ item.forum }}</div>
|
<div class="result-label">{{ item.forum }}</div>
|
||||||
<div class="result-title" v-html="item.subject"></div>
|
<div class="result-title" v-html="item.subject"></div>
|
||||||
@ -95,8 +95,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
historicalSearch(val, oldval) {
|
historicalSearch(val, oldval) {
|
||||||
if (val.length > 10) this.historicalSearch.slice(0, 10)
|
console.log("val", val);
|
||||||
this.$store.commit('setHistoricalSearch', 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() {
|
handleSearchResult() {
|
||||||
let kw = this.kw
|
let kw = this.kw
|
||||||
// this.historicalSearch.push(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()
|
this.getSearchResult()
|
||||||
},
|
},
|
||||||
@ -147,7 +151,10 @@ export default {
|
|||||||
this.getSearchResult()
|
this.getSearchResult()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 跳转详情
|
||||||
|
toDetail(tid) {
|
||||||
|
this.$router.push(`/detailIndex?tid=${tid}`)
|
||||||
|
},
|
||||||
|
|
||||||
// 点击清空 input 的值
|
// 点击清空 input 的值
|
||||||
emptyKw() {
|
emptyKw() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user