props.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. import { defineProps } from '../../libs/util/props';
  2. import theme from '../../libs/config/theme.js';
  3. export default defineProps('input', {
  4. // 输入的值
  5. //#ifdef VUE2
  6. value: {
  7. type: [String, Number],
  8. default: ''
  9. },
  10. // #endif
  11. // #ifdef VUE3
  12. modelValue: {
  13. type: [String, Number],
  14. default: ''
  15. },
  16. // #endif
  17. // 输入框类型
  18. // number-数字输入键盘,app-vue下可以输入浮点数,app-nvue和小程序平台下只能输入整数
  19. // idcard-身份证输入键盘,微信、支付宝、百度、QQ小程序
  20. // digit-带小数点的数字键盘,App的nvue页面、微信、支付宝、百度、头条、QQ小程序
  21. // text-文本输入键盘
  22. type: {
  23. type: String,
  24. default: 'text'
  25. },
  26. // 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,
  27. // 兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序
  28. fixed: {
  29. type: Boolean,
  30. default: false
  31. },
  32. // 是否禁用输入框
  33. disabled: {
  34. type: Boolean,
  35. default: false
  36. },
  37. // 禁用状态时的背景色
  38. disabledColor: {
  39. type: String,
  40. default: '#f5f7fa'
  41. },
  42. // 是否显示清除控件
  43. clearable: {
  44. type: Boolean,
  45. default: false
  46. },
  47. // 是否密码类型
  48. password: {
  49. type: Boolean,
  50. default: false
  51. },
  52. // 是否显示密码切换的眼睛图标
  53. showPasswordToggle: {
  54. type: Boolean,
  55. default: true
  56. },
  57. // 最大输入长度,设置为 -1 的时候不限制最大长度
  58. maxlength: {
  59. type: [String, Number],
  60. default: -1
  61. },
  62. // 输入框为空时的占位符
  63. placeholder: {
  64. type: String,
  65. default: ''
  66. },
  67. // 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
  68. placeholderClass: {
  69. type: String,
  70. default: 'input-placeholder'
  71. },
  72. // 指定placeholder的样式
  73. placeholderStyle: {
  74. type: [String, Object],
  75. default: 'color: #c0c4cc'
  76. },
  77. // 设置右下角按钮的文字,有效值:send|search|next|go|done,兼容性详见uni-app文档
  78. // https://uniapp.dcloud.io/component/input
  79. // https://uniapp.dcloud.io/component/textarea
  80. confirmType: {
  81. type: String,
  82. default: 'done'
  83. },
  84. // 点击键盘右下角按钮时是否保持键盘不收起,H5无效
  85. confirmHold: {
  86. type: Boolean,
  87. default: false
  88. },
  89. // focus时,点击页面的时候不收起键盘,微信小程序有效
  90. holdKeyboard: {
  91. type: Boolean,
  92. default: false
  93. },
  94. // 自动获取焦点
  95. // 在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点
  96. focus: {
  97. type: Boolean,
  98. default: false
  99. },
  100. // 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效
  101. autoBlur: {
  102. type: Boolean,
  103. default: false
  104. },
  105. // 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效
  106. disableDefaultPadding: {
  107. type: Boolean,
  108. default: false
  109. },
  110. // 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 ( 默认 false )
  111. alwaysEmbed: {
  112. type: [Boolean],
  113. default: false
  114. },
  115. // 指定focus时光标的位置
  116. cursor: {
  117. type: [String, Number],
  118. default: -1
  119. },
  120. // 输入框聚焦时底部与键盘的距离
  121. cursorSpacing: {
  122. type: [String, Number],
  123. default: 30
  124. },
  125. // 光标起始位置,自动聚集时有效,需与selection-end搭配使用
  126. selectionStart: {
  127. type: [String, Number],
  128. default: -1
  129. },
  130. // 光标结束位置,自动聚集时有效,需与selection-start搭配使用
  131. selectionEnd: {
  132. type: [String, Number],
  133. default: -1
  134. },
  135. // 键盘弹起时,是否自动上推页面
  136. adjustPosition: {
  137. type: Boolean,
  138. default: true
  139. },
  140. // 输入框内容对齐方式,可选值为:left|center|right
  141. inputAlign: {
  142. type: String,
  143. default: 'left'
  144. },
  145. // 输入框字体的大小
  146. fontSize: {
  147. type: [String, Number],
  148. default: '15px'
  149. },
  150. // 输入框字体颜色
  151. color: {
  152. type: String,
  153. default: theme.contentColor
  154. },
  155. // 输入框前置图标
  156. prefixIcon: {
  157. type: String,
  158. default: ''
  159. },
  160. // 前置图标样式,对象或字符串
  161. prefixIconStyle: {
  162. type: [String, Object],
  163. default: ''
  164. },
  165. // 输入框后置图标
  166. suffixIcon: {
  167. type: String,
  168. default: ''
  169. },
  170. // 后置图标样式,对象或字符串
  171. suffixIconStyle: {
  172. type: [String, Object],
  173. default: ''
  174. },
  175. // 边框类型,surround-四周边框,bottom-底部边框,none-无边框
  176. border: {
  177. type: String,
  178. default: 'surround'
  179. },
  180. // 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会
  181. readonly: {
  182. type: Boolean,
  183. default: false
  184. },
  185. // 输入框形状,circle-圆形,square-方形
  186. shape: {
  187. type: String,
  188. default: 'square'
  189. },
  190. // 用于处理或者过滤输入框内容的方法
  191. formatter: {
  192. type: [Function, null],
  193. default: null
  194. },
  195. // 是否忽略组件内对文本合成系统事件的处理
  196. ignoreCompositionEvent: {
  197. type: Boolean,
  198. default: false
  199. },
  200. eyeIconSize: {
  201. type: [String, Number],
  202. default: 20
  203. },
  204. eyeIconColor: {
  205. type: String,
  206. default: '#909399'
  207. },
  208. // 背景颜色
  209. backgroundColor: {
  210. type: String,
  211. default: ''
  212. },
  213. // 边框圆角
  214. round: {
  215. type: String,
  216. default: '4px'
  217. },
  218. // 边框颜色
  219. borderColor: {
  220. type: String,
  221. default: ''
  222. },
  223. // 指定focus时光标颜色
  224. cursorColor: {
  225. type: String,
  226. default: ''
  227. }
  228. })