| | |
| | | <template> |
| | | <span class=""> |
| | | <a-icon type="search" style="font-size: 16px; cursor: pointer;" @click="enterSearchMode"/> |
| | | <span class="header-search"> |
| | | <a-icon type="search" class="search-icon" @click="enterSearchMode"/> |
| | | <a-auto-complete |
| | | ref="input" |
| | | :dataSource="dataSource" |
| | | :class="[searchMode ? 'enterSearch' : 'leaveSearch']" |
| | | :class="['search-input', searchMode ? 'enter' : 'leave']" |
| | | placeholder="站内搜索" |
| | | @blur="leaveSearchMode" |
| | | > |
| | | <a-input style="" /> |
| | | </a-auto-complete> |
| | | </span> |
| | | </template> |
| | |
| | | methods: { |
| | | enterSearchMode () { |
| | | this.searchMode = true |
| | | this.$refs.input.focus() |
| | | setTimeout(() => this.$refs.input.focus(), 300) |
| | | }, |
| | | leaveSearchMode () { |
| | | this.searchMode = false |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .enterSearch { |
| | | width: 225px; |
| | | border-bottom: 1px rgba(3, 5, 6, 0.23) solid; |
| | | transition: width 0.3s ease-in-out; |
| | | <style lang="less"> |
| | | .header-search{ |
| | | .search-icon{ |
| | | font-size: 16px; |
| | | cursor: pointer; |
| | | } |
| | | .leaveSearch { |
| | | width: 0px; |
| | | border-bottom: 1px rgba(3, 5, 6, 0.23) solid; |
| | | transition: width 0.3s ease-in-out; |
| | | } |
| | | .enterSearch input, .leaveSearch input { |
| | | .search-input{ |
| | | border: 0; |
| | | } |
| | | .enterSearch input:focus { |
| | | border-bottom: 1px rgba(3, 5, 6, 0.23) solid; |
| | | transition: width 0.3s ease-in-out; |
| | | input{ |
| | | border: 0; |
| | | box-shadow: 0 0 0 0; |
| | | } |
| | | .leaveSearch input{ |
| | | &.leave{ |
| | | width: 0px; |
| | | border: 0; |
| | | input{ |
| | | display: none; |
| | | } |
| | | .fade-enter-active, .fade-leave-active { |
| | | transition: width .3s; |
| | | } |
| | | .fade-enter{ |
| | | &.enter{ |
| | | width: 200px; |
| | | input:focus{ |
| | | box-shadow: 0 0 0 0; |
| | | } |
| | | .fade-leave{ |
| | | width: 0px; |
| | | } |
| | | } |
| | | } |
| | | </style> |