您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

216 行
6.2 KiB

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