Search.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="search">
  3. <slot name="left"></slot>
  4. <van-search :placeholder="placeholder" :left-icon="leftIcon" @search="onSearch" show-action v-model="searchValue">
  5. <template slot="action" >
  6. <span @click="onSearch" class="search_btn">搜索</span>
  7. </template>
  8. </van-search>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. placeholder: { // 提示文字
  15. type: String,
  16. default: '请输入搜索关键词'
  17. }
  18. },
  19. data() {
  20. return {
  21. leftIcon: require('@/assets/images/common/icon_search.png'),
  22. searchValue: ""
  23. };
  24. },
  25. methods: {
  26. onSearch() {
  27. this.$emit("onSearch", this.searchValue);
  28. }
  29. }
  30. };
  31. </script>
  32. <style lang="less" scoped>
  33. @import url("../assets/commonLess/variable.less");
  34. .search {
  35. overflow: hidden;
  36. background-color: #fff !important;
  37. display: flex;
  38. align-items: center;
  39. padding: 0 12px;
  40. /deep/.van-search {
  41. flex: 1;
  42. background-color: #fff !important;
  43. margin: 15px 0;
  44. padding: 0;
  45. border-radius: 20px;
  46. overflow: hidden;
  47. /deep/.van-cell {
  48. display: flex;
  49. justify-content: center;
  50. align-items: center;
  51. }
  52. /deep/.van-field__control {
  53. font-size: 16px;
  54. }
  55. }
  56. /deep/.van-cell__value {
  57. height: 24px !important;
  58. }
  59. /deep/.van-search__action {
  60. color: @tFontColor;
  61. background-color: #f5f5f5;
  62. padding: 0 5px;
  63. }
  64. /deep/.van-search__content {
  65. background-color: #f5f5f5;
  66. }
  67. /deep/.van-field__left-icon {
  68. margin-top: 3px;
  69. height: 21px;
  70. }
  71. .search_btn {
  72. background: #01C1B5;
  73. font-size: 14px;
  74. color: #fff;
  75. padding: 4px 9px;
  76. border-radius: 15px;
  77. }
  78. }
  79. input::-webkit-input-placeholder {
  80. color: #777 !important;
  81. font-size: .14rem;
  82. }
  83. input:-moz-placeholder {
  84. color: #777 !important;
  85. font-size: .14rem;
  86. }
  87. input::-moz-placeholder {
  88. color: #777 !important;
  89. font-size: .14rem;
  90. }
  91. input:-ms-input-placeholder {
  92. color: #777 !important;
  93. font-size: .14rem;
  94. }
  95. </style>