Search.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="search-container van-fade-an">
  3. <div class="click-pop" v-if="type === 'click'" @click="onClick"></div>
  4. <van-search @input="$emit('input', $event)" @search="onSearch" class="my-search" left-icon="diy-search" v-model.trim="input" placeholder="搜索文档" />
  5. </div>
  6. </template>
  7. <script lang="ts">
  8. import { Component, Vue, Prop } from 'vue-property-decorator'
  9. import { Icon, Search } from 'vant'
  10. // @ is an alias to /src
  11. @Component({
  12. name: 'Search',
  13. components: {
  14. [Search.name]: Search,
  15. [Icon.name]: Icon
  16. }
  17. })
  18. export default class Empty extends Vue {
  19. @Prop({ default: 'input' }) type?: string | undefined;
  20. input = ''
  21. onSearch () {
  22. this.$emit('submit', this.input)
  23. }
  24. onClick () {
  25. if (this.type === 'click') {
  26. this.$emit('click')
  27. }
  28. }
  29. }
  30. </script>
  31. <style scoped lang="scss">
  32. @keyframes show {
  33. to {
  34. opacity: 1;
  35. }
  36. }
  37. .van-fade-an {
  38. opacity: 0;
  39. animation: show 1s 300ms ease forwards;
  40. z-index: 666;
  41. position: relative;
  42. }
  43. .click-pop {
  44. position: absolute;
  45. width: 100%;
  46. height: 100%;
  47. z-index: 99;
  48. opacity: 0;
  49. }
  50. .search-container {
  51. width: 100%;
  52. }
  53. .my-search {
  54. &::v-deep.van-search {
  55. padding: 7px 16px;
  56. .van-search__content {
  57. border-radius: 8px;
  58. background: #F5F6F7;
  59. border: 1px solid rgba(0, 0, 0, 0.05);
  60. }
  61. .van-cell {
  62. align-items: center;
  63. height: 38px;
  64. }
  65. .van-field__left-icon {
  66. height: 20px;
  67. margin-right: 8px;
  68. }
  69. .van-field__control {
  70. color: #171826;
  71. font-family: PingFang SC;
  72. font-size: 14px;
  73. letter-spacing: 0px;
  74. text-align: left;
  75. }
  76. }
  77. @include diy-icon('search', 20, 20)
  78. }
  79. </style>