index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div class="simple-search">
  3. <input
  4. type="text"
  5. :placeholder="placeholder"
  6. v-model="inputVal"
  7. @input="(e) => $emit('input', e.target.value)"
  8. @keyup.enter="$emit('search', inputVal)"
  9. />
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. model: {
  15. prop: 'value',
  16. event: 'input',
  17. },
  18. props: {
  19. value: {
  20. type: String,
  21. default: '',
  22. },
  23. placeholder: {
  24. type: String,
  25. default: '',
  26. },
  27. },
  28. data() {
  29. return {
  30. inputVal: '',
  31. }
  32. },
  33. }
  34. </script>
  35. <style scoped lang="scss">
  36. @media screen and (min-width: 768px) {
  37. .simple-search {
  38. &::before {
  39. content: '';
  40. display: block;
  41. background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
  42. no-repeat center;
  43. width: 30px;
  44. height: 30px;
  45. position: absolute;
  46. background-size: 26px;
  47. top: 50%;
  48. left: 6px;
  49. transform: translateY(-50%);
  50. z-index: 9;
  51. }
  52. input {
  53. position: relative;
  54. display: block;
  55. width: 560px;
  56. height: 40px;
  57. background: rgba(255, 255, 255, 0.39);
  58. border-radius: 4px;
  59. outline: none;
  60. font-size: 16px;
  61. line-height: 40px;
  62. border: 0;
  63. padding-left: 44px;
  64. box-sizing: border-box;
  65. color: #fff;
  66. }
  67. }
  68. }
  69. @media screen and (max-width: 768px) {
  70. .simple-search {
  71. width: 92vw;
  72. height: 9.6vw;
  73. box-shadow: 0px 0.4vw 1vw rgba(51, 51, 51, 0.08);
  74. padding-left: 9.6vw;
  75. padding-right: 1.6vw;
  76. left: 50%;
  77. top: 0;
  78. background-color: #fff;
  79. border-radius: 0.4vw;
  80. &::before {
  81. content: '';
  82. display: block;
  83. background: url(https://static.caimei365.com/www/authentic/h5/icon-search.png)
  84. no-repeat;
  85. width: 6.4vw;
  86. height: 6.4vw;
  87. position: absolute;
  88. background-size: 6.4vw;
  89. left: 1.6vw;
  90. top: 1.6vw;
  91. }
  92. input {
  93. display: block;
  94. width: 100%;
  95. height: 9.6vw;
  96. line-height: 9.6vw;
  97. outline: none;
  98. }
  99. }
  100. }
  101. </style>