Commit 56a02ffb authored by Damon's avatar Damon

perf: 搜索

parent 71f25dcf
......@@ -178,12 +178,13 @@ export default {
search(val) {
if (val){
this.keyword = val
let history = this.searchHistory
let history = this.searchHistory.filter(v => v !== val)
history.unshift(val)
if (history.length > 9) {
history.splice(9, 1)
}
this.$u.vuex('searchHistory', history)
this.init()
}
},
collection(item) {
......
......@@ -43,8 +43,7 @@
export default {
data() {
return {
keyword: '',
history: [],
keyword: ''
}
},
computed: {
......@@ -56,19 +55,20 @@ export default {
deleteImg() {
return process.uniEnv.qn_base_url + 'delete.png'
},
},
created() {
this.history = this.searchHistory
history() {
return this.searchHistory
}
},
methods: {
search(val) {
if (val){
this.keyword = val
this.history.unshift(val)
if(this.history.length > 9){
this.history.splice(9, 1)
let history = this.searchHistory.filter(v => v !== val)
history.unshift(val)
if(history.length > 9){
history.splice(9, 1)
}
this.$u.vuex('searchHistory', this.history)
this.$u.vuex('searchHistory', history)
this.toSearchDetail(val)
}
},
......@@ -86,7 +86,6 @@ export default {
content: '确认要清空搜索历史记录?',
success: (res) => {
if (res.confirm) {
this.history = []
this.$u.vuex('searchHistory', [])
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment