Commit aff9a88c4be546373131bccfeb5e70a6fa8ec098
1 parent
f534f270
获取keyword后自动搜索处理~
Showing
1 changed file
with
18 additions
and
9 deletions
src/pages/search/search.vue
| @@ -201,12 +201,15 @@ | @@ -201,12 +201,15 @@ | ||
| 201 | // 设置搜索历史和会话搜索关键字 | 201 | // 设置搜索历史和会话搜索关键字 |
| 202 | this.getSearchHistoryArr(); | 202 | this.getSearchHistoryArr(); |
| 203 | 203 | ||
| 204 | - // 判断如果有搜索关键字,进行搜索 | ||
| 205 | - if (this.$refs.searchCom.getKeyword()) { | 204 | + this.$nextTick(() => { |
| 206 | 205 | ||
| 207 | - // 搜索 | ||
| 208 | - this.doConfirm(this.$refs.searchCom.getKeyword()); | ||
| 209 | - } | 206 | + // 判断如果有搜索关键字,进行搜索 |
| 207 | + if (this.$refs.searchCom.getKeyword()) { | ||
| 208 | + | ||
| 209 | + // 搜索 | ||
| 210 | + this.doConfirm(this.$refs.searchCom.getKeyword()); | ||
| 211 | + } | ||
| 212 | + }) | ||
| 210 | }, | 213 | }, |
| 211 | 214 | ||
| 212 | /** | 215 | /** |
| @@ -790,8 +793,11 @@ | @@ -790,8 +793,11 @@ | ||
| 790 | // 设置会话keyword | 793 | // 设置会话keyword |
| 791 | if (window.sessionStorage.getItem("keyword")) { | 794 | if (window.sessionStorage.getItem("keyword")) { |
| 792 | 795 | ||
| 793 | - // 设置搜索关键字 | ||
| 794 | - this.$refs.searchCom.setKeyword(window.sessionStorage.getItem("keyword")); | 796 | + this.$nextTick(() => { |
| 797 | + | ||
| 798 | + // 设置搜索关键字 | ||
| 799 | + this.$refs.searchCom.setKeyword(window.sessionStorage.getItem("keyword")); | ||
| 800 | + }); | ||
| 795 | } | 801 | } |
| 796 | 802 | ||
| 797 | // 处理搜索历史Storage数组 | 803 | // 处理搜索历史Storage数组 |
| @@ -811,8 +817,11 @@ | @@ -811,8 +817,11 @@ | ||
| 811 | // 设置会话keyword | 817 | // 设置会话keyword |
| 812 | window.sessionStorage.setItem("keyword", keyword); | 818 | window.sessionStorage.setItem("keyword", keyword); |
| 813 | 819 | ||
| 814 | - // 设置input值,通过历史记录搜索时,会用到 | ||
| 815 | - this.$refs.searchCom.setKeyword(keyword); | 820 | + this.$nextTick(() => { |
| 821 | + | ||
| 822 | + // 设置input值,通过历史记录搜索时,会用到 | ||
| 823 | + this.$refs.searchCom.setKeyword(keyword); | ||
| 824 | + }); | ||
| 816 | 825 | ||
| 817 | // 处理搜索历史Storage数组 | 826 | // 处理搜索历史Storage数组 |
| 818 | if (!window.localStorage.getItem("searchHistoryArr")) { | 827 | if (!window.localStorage.getItem("searchHistoryArr")) { |