index.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="u-search">
  3. <view class="u-search-input">
  4. <van-search :value="searchKeyword" :placeholder="placeholder" use-action-slot class="van-search"
  5. @change="query" @search="onClickSearch">
  6. <view class="u-search-text" slot="action" @tap="onClickSearch">搜索</view>
  7. </van-search>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. import VanSearch from '@/wxcomponents/vant/search/index'
  13. export default {
  14. options: {
  15. styleIsolation: 'shared'
  16. },
  17. components: {
  18. VanSearch
  19. },
  20. props: {
  21. value: String,
  22. placeholder: {
  23. type: String,
  24. default: ''
  25. }
  26. },
  27. computed: {},
  28. watch: {
  29. searchKeyword(val) {
  30. this.$emit('input', val)
  31. },
  32. value(val) {
  33. this.searchKeyword = this.value
  34. }
  35. },
  36. data() {
  37. return {
  38. searchKeyword: ''
  39. }
  40. },
  41. created() {
  42. this.searchKeyword = this.value
  43. },
  44. mounted() {},
  45. methods: {
  46. query(e) {
  47. this.searchKeyword = e.detail
  48. },
  49. onClickSearch() {
  50. this.$emit('search')
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .u-search {
  57. .u-search-input {
  58. height: 64rpx;
  59. border-radius: 50rpx;
  60. background-color: #FFFFFF;
  61. box-shadow: 0 4rpx 4rpx 0 rgba(0, 0, 0, 0.15);
  62. border: 2rpx solid #D9D9D9;
  63. padding: 4rpx;
  64. overflow: hidden;
  65. .van-field__placeholder {
  66. font-size: $fontSize2;
  67. }
  68. .van-cell__left-icon-wrap {
  69. height: 50rpx;
  70. }
  71. .van-field__control {
  72. font-size: $fontSize2;
  73. height: 50rpx;
  74. }
  75. }
  76. .van-search {
  77. --search-padding: 0rpx;
  78. --search-input-height: 34rpx;
  79. --search-background-color: #FFFFFF;
  80. padding-right: 24rpx;
  81. font-size: $fontSize2;
  82. }
  83. .u-search-text {
  84. font-size: $fontSize2;
  85. }
  86. .van-search__action {
  87. color: #333333;
  88. }
  89. .van-icon {
  90. color: #D4D4D6;
  91. }
  92. .van-cell {
  93. padding: 2rpx 0rpx 2rpx !important;
  94. }
  95. }
  96. </style>