index.vue 1.6 KB

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