index.vue 2.1 KB

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