fix bug
This commit is contained in:
		| @@ -10,7 +10,6 @@ | |||||||
|       remote |       remote | ||||||
|       placeholder="Search" |       placeholder="Search" | ||||||
|       class="header-search-select" |       class="header-search-select" | ||||||
|       @blur="blur" |  | ||||||
|       @change="change"> |       @change="change"> | ||||||
|       <el-option v-for="item in options" :key="item.path" :value="item" :label="item.title.join(' > ')"/> |       <el-option v-for="item in options" :key="item.path" :value="item" :label="item.title.join(' > ')"/> | ||||||
|     </el-select> |     </el-select> | ||||||
| @@ -50,6 +49,13 @@ export default { | |||||||
|     }, |     }, | ||||||
|     searchPool(list) { |     searchPool(list) { | ||||||
|       this.initFuse(list) |       this.initFuse(list) | ||||||
|  |     }, | ||||||
|  |     show(value) { | ||||||
|  |       if (value) { | ||||||
|  |         document.body.addEventListener('click', this.close) | ||||||
|  |       } else { | ||||||
|  |         document.body.removeEventListener('click', this.close) | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   mounted() { |   mounted() { | ||||||
| @@ -62,7 +68,7 @@ export default { | |||||||
|         this.$refs.headerSearchSelect.focus() |         this.$refs.headerSearchSelect.focus() | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     blur() { |     close() { | ||||||
|       this.$refs.headerSearchSelect.blur() |       this.$refs.headerSearchSelect.blur() | ||||||
|       this.options = [] |       this.options = [] | ||||||
|       this.show = false |       this.show = false | ||||||
| @@ -70,6 +76,10 @@ export default { | |||||||
|     change(val) { |     change(val) { | ||||||
|       this.$router.push(val.path) |       this.$router.push(val.path) | ||||||
|       this.search = '' |       this.search = '' | ||||||
|  |       this.options = [] | ||||||
|  |       this.$nextTick(() => { | ||||||
|  |         this.show = false | ||||||
|  |       }) | ||||||
|     }, |     }, | ||||||
|     initFuse(list) { |     initFuse(list) { | ||||||
|       this.fuse = new Fuse(list, { |       this.fuse = new Fuse(list, { | ||||||
| @@ -108,8 +118,11 @@ export default { | |||||||
|           const i18ntitle = i18n.t(`route.${router.meta.title}`) |           const i18ntitle = i18n.t(`route.${router.meta.title}`) | ||||||
|           data.title = [...data.title, i18ntitle] |           data.title = [...data.title, i18ntitle] | ||||||
|  |  | ||||||
|           // only push the routes with title |           if (router.redirect !== 'noredirect') { | ||||||
|           res.push(data) |             // only push the routes with title | ||||||
|  |             // special case: need to exclude parent router without redirect | ||||||
|  |             res.push(data) | ||||||
|  |           } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // recursive child routers |         // recursive child routers | ||||||
| @@ -145,7 +158,7 @@ export default { | |||||||
|  |  | ||||||
|   .header-search-select { |   .header-search-select { | ||||||
|     font-size: 18px; |     font-size: 18px; | ||||||
|     transition: width 0.3s; |     transition: width 0.2s; | ||||||
|     width: 0; |     width: 0; | ||||||
|     overflow: hidden; |     overflow: hidden; | ||||||
|     background: transparent; |     background: transparent; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user