研发图纸文件管理系统-前端项目
chenghx
2018-07-20 354ba9a734b63ac037a887137107f159d785f715
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<template>
  <span class="header-item">
    <a-icon type="search" style="font-size: 16px; cursor: pointer;" @click="enterSearchMode"/>
    <a-auto-complete
      ref="input"
      :dataSource="dataSource"
      :class="[searchMode ? 'enterSearch' : 'leaveSearch']"
      placeholder="站内搜索"
      @blur="leaveSearchMode"
    >
      <a-input style="" />
    </a-auto-complete>
  </span>
</template>
 
<script>
import AIcon from 'vue-antd-ui/es/icon/icon'
import AAutoComplete from 'vue-antd-ui/es/auto-complete/index'
import AInput from 'vue-antd-ui/es/input/Input'
export default {
  name: 'HeaderSearch',
  components: {AInput, AAutoComplete, AIcon},
  data () {
    return {
      dataSource: ['选项一', '选项二'],
      searchMode: false
    }
  },
  methods: {
    enterSearchMode () {
      this.searchMode = true
      this.$refs.input.focus()
    },
    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;
  }
  .leaveSearch {
    width: 0px;
    border-bottom: 1px rgba(3, 5, 6, 0.23) solid;
    transition: width 0.3s ease-in-out;
  }
  .enterSearch input, .leaveSearch input {
    border: 0;
  }
  .enterSearch input:focus {
    border: 0;
    box-shadow: 0 0 0 0;
  }
  .leaveSearch input{
    width: 0px;
    border: 0;
  }
  .fade-enter-active, .fade-leave-active {
    transition: width .3s;
  }
  .fade-enter{
    width: 200px;
  }
  .fade-leave{
    width: 0px;
  }
  .header-item{
    margin: 0 12px;
  }
</style>