u--textarea.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <uvTextarea
  3. <!-- #ifdef VUE2 -->
  4. :value="value"
  5. @input="e => $emit('input', e)"
  6. <!-- #endif -->
  7. <!-- #ifdef VUE3 -->
  8. :modelValue="modelValue"
  9. @update:modelValue="e => $emit('update:modelValue', e)"
  10. <!-- #endif -->
  11. :placeholder="placeholder"
  12. :placeholderStyle="placeholderStyle"
  13. :placeholderClass="placeholderClass"
  14. :height="height"
  15. :confirmType="confirmType"
  16. :disabled="disabled"
  17. :count="count"
  18. :focus="focus"
  19. :autoHeight="autoHeight"
  20. :fixed="fixed"
  21. :cursorSpacing="cursorSpacing"
  22. :cursor="cursor"
  23. :showConfirmBar="showConfirmBar"
  24. :selectionStart="selectionStart"
  25. :selectionEnd="selectionEnd"
  26. :adjustPosition="adjustPosition"
  27. :disableDefaultPadding="disableDefaultPadding"
  28. :holdKeyboard="holdKeyboard"
  29. :maxlength="maxlength"
  30. :border="border"
  31. :round="round"
  32. :borderColor="borderColor"
  33. :backgroundColor="backgroundColor"
  34. :customStyle="customStyle"
  35. :formatter="formatter"
  36. :ignoreCompositionEvent="ignoreCompositionEvent"
  37. @focus="e => $emit('focus', e)"
  38. @blur="e => $emit('blur', e)"
  39. @linechange="e => $emit('linechange', e)"
  40. @confirm="e => $emit('confirm', e)"
  41. @keyboardheightchange="e => $emit('keyboardheightchange', e)"
  42. ></uvTextarea>
  43. </template>
  44. <script>
  45. /**
  46. * 此组件存在的理由是,在nvue下,u--textarea被uni-app官方占用了,u-textarea在nvue中相当于textarea组件
  47. * 所以在nvue下,取名为u--textarea,内部其实还是u-textarea.vue,只不过做一层中转
  48. */
  49. import uvTextarea from '../u-textarea/u-textarea.vue';
  50. import props from '../u-textarea/props.js'
  51. import mixin from '../../libs/mixin/mixin'
  52. import mpMixin from '../../libs/mixin/mpMixin'
  53. /**
  54. * Textarea 文本域
  55. * @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等
  56. * @tutorial https://uview.d3u.cn/components/textarea.html
  57. *
  58. * @property {String | Number} value 输入框的内容
  59. * @property {String | Number} placeholder 输入框为空时占位符
  60. * @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
  61. * @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;"
  62. * @property {String | Number} height 输入框高度(默认 70 )
  63. * @property {String} confirmType 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效(默认 'done' )
  64. * @property {Boolean} disabled 是否禁用(默认 false )
  65. * @property {Boolean} count 是否显示统计字数(默认 false )
  66. * @property {Boolean} focus 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现(默认 false )
  67. * @property {Boolean | Function} autoHeight 是否自动增加高度(默认 false )
  68. * @property {Boolean} fixed 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true(默认 false )
  69. * @property {Number} cursorSpacing 指定光标与键盘的距离(默认 0 )
  70. * @property {String | Number} cursor 指定focus时的光标位置
  71. * @property {Function} formatter 内容式化函数
  72. * @property {Boolean} showConfirmBar 是否显示键盘上方带有”完成“按钮那一栏,(默认 true )
  73. * @property {Number} selectionStart 光标起始位置,自动聚焦时有效,需与selection-end搭配使用,(默认 -1 )
  74. * @property {Number | Number} selectionEnd 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认 -1 )
  75. * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面(默认 true )
  76. * @property {Boolean | Number} disableDefaultPadding 是否去掉 iOS 下的默认内边距,只微信小程序有效(默认 false )
  77. * @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,只微信小程序有效(默认 false )
  78. * @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认 140 )
  79. * @property {String} border 边框类型,surround-四周边框,none-无边框,bottom-底部边框(默认 'surround' )
  80. * @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理
  81. * @property {String} backgroundColor 背景颜色
  82. *@property {String} round 边框圆角
  83. * @property {String} borderColor 边框颜色
  84. *
  85. *
  86. * @event {Function(e)} focus 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度
  87. * @event {Function(e)} blur 输入框失去焦点时触发,event.detail = {value, cursor}
  88. * @event {Function(e)} linechange 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
  89. * @event {Function(e)} input 当键盘输入时,触发 input 事件
  90. * @event {Function(e)} confirm 点击完成时, 触发 confirm 事件
  91. * @event {Function(e)} keyboardheightchange 键盘高度发生变化的时候触发此事件
  92. * @example <u--textarea v-model="value1" placeholder="请输入内容" ></u--textarea>
  93. */
  94. export default {
  95. name: 'u--textarea',
  96. mixins: [mpMixin, mixin, props],
  97. components: {
  98. uvTextarea
  99. },
  100. }
  101. </script>