fxyk-search.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <u-search placeholder="输入项目名称或关键字" :bg-color="backgroundColor" :border-color="borderColor" :placeholder-color="placeholderColor" :disabled="disabled" :show-action="false" :input-style="{'padding-left':'20rpx'}" :height="height" :search-icon-color="searchIconColor" v-model="value" :style="padding_show" @click="jump_search"></u-search>
  3. </template>
  4. <script>
  5. import { mapGetters } from 'vuex'
  6. export default {
  7. props: {
  8. // 搜索框背景颜色
  9. backgroundColor: {
  10. type: String,
  11. default: "#fff"
  12. },
  13. // 搜索框边框颜色
  14. borderColor: {
  15. type: String,
  16. default: "black"
  17. },
  18. // 提示文字颜色
  19. placeholderColor: {
  20. type: String,
  21. default: "black"
  22. },
  23. //输入框高度
  24. height: {
  25. type: String,
  26. default: "64"
  27. },
  28. // 是否启用输入框
  29. disabled: {
  30. type: Boolean,
  31. default: false
  32. },
  33. // 搜索框图标颜色
  34. searchIconColor: {
  35. type: String,
  36. default: "black"
  37. },
  38. // Y轴内边距
  39. paddingY: {
  40. type: Number,
  41. default: 0
  42. },
  43. // X轴内边距
  44. paddingX: {
  45. type: Number,
  46. default: 0
  47. }
  48. },
  49. data() {
  50. return {
  51. value: ''
  52. }
  53. },
  54. computed: {
  55. ...mapGetters(['searchItemData']),
  56. padding_show() {
  57. return {'padding-top': this.paddingY+'rpx',
  58. 'padding-bottom': this.paddingY+'rpx',
  59. 'padding-left': this.paddingX+'rpx',
  60. 'padding-right': this.paddingX+'rpx'}
  61. }
  62. },
  63. methods: {
  64. // 跳到搜索页
  65. jump_search() {
  66. uni.navigateTo({url: '/pages/index/search'})
  67. }
  68. },
  69. watch: {
  70. searchItemData(val) {
  71. this.value = val
  72. }
  73. }
  74. }
  75. </script>
  76. <style>
  77. </style>