props.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { defineProps } from '../../libs/util/props';
  2. export default defineProps('search', {
  3. // 搜索框形状,round-圆形,square-方形
  4. shape: {
  5. type: String,
  6. default: 'round'
  7. },
  8. // 搜索框背景色,默认值#f2f2f2
  9. bgColor: {
  10. type: String,
  11. default: '#f2f2f2'
  12. },
  13. // 占位提示文字
  14. placeholder: {
  15. type: String,
  16. default: () => uni.$u.$t('uSearch.placeholder')
  17. },
  18. // 是否启用清除控件
  19. clearabled: {
  20. type: Boolean,
  21. default: true
  22. },
  23. // 是否自动聚焦
  24. focus: {
  25. type: Boolean,
  26. default: false
  27. },
  28. // 是否在搜索框右侧显示取消按钮
  29. showAction: {
  30. type: Boolean,
  31. default: true
  32. },
  33. // 右边控件的样式
  34. actionStyle: {
  35. type: Object,
  36. default: () => ({})
  37. },
  38. // 取消按钮文字
  39. actionText: {
  40. type: String,
  41. default: () => uni.$u.$t('uSearch.actionText')
  42. },
  43. // 输入框内容对齐方式,可选值为 left|center|right
  44. inputAlign: {
  45. type: String,
  46. default: 'left'
  47. },
  48. // input输入框的样式,可以定义文字颜色,大小等,对象形式
  49. inputStyle: {
  50. type: Object,
  51. default: () => ({})
  52. },
  53. // 是否启用输入框
  54. disabled: {
  55. type: Boolean,
  56. default: false
  57. },
  58. // 边框颜色
  59. borderColor: {
  60. type: String,
  61. default: 'transparent'
  62. },
  63. // 搜索图标的颜色,默认同输入框字体颜色
  64. searchIconColor: {
  65. type: String,
  66. default: '#909399'
  67. },
  68. // 输入框字体颜色
  69. color: {
  70. type: String,
  71. default: '#606266'
  72. },
  73. // placeholder的颜色
  74. placeholderColor: {
  75. type: String,
  76. default: '#909399'
  77. },
  78. // 左边输入框的图标,可以为uView图标名称或图片路径
  79. searchIcon: {
  80. type: [String, Boolean],
  81. default: 'search'
  82. },
  83. searchIconSize: {
  84. type: [Number, String],
  85. default: 22
  86. },
  87. // 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30px"、"30px 20px"等写法
  88. margin: {
  89. type: String,
  90. default: '0'
  91. },
  92. // 开启showAction时,是否在input获取焦点时才显示
  93. animation: {
  94. type: Boolean,
  95. default: false
  96. },
  97. // 输入框的初始化内容
  98. // #ifdef VUE2
  99. value: {
  100. type: String,
  101. default: ''
  102. },
  103. // #endif
  104. // #ifdef VUE3
  105. modelValue: {
  106. type: String,
  107. default: ''
  108. },
  109. // #endif
  110. // 输入框最大能输入的长度,-1为不限制长度(来自uniapp文档)
  111. maxlength: {
  112. type: [String, Number],
  113. default: -1
  114. },
  115. // 搜索框高度,单位px
  116. height: {
  117. type: [String, Number],
  118. default: 32
  119. },
  120. // 搜索框左侧文本
  121. label: {
  122. type: [String, Number, null],
  123. default: null
  124. }
  125. })