You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

81 lines
1.8 KiB

  1. <template>
  2. <view v-if="!simpleMode" :class="className" :style="style">
  3. <view class="cu-form-group" style="border-bottom: none; padding-bottom: 0;">
  4. <view class="title">
  5. <text v-if="required" style="color: red; font-size: 1.2em;">*</text>
  6. {{ title || '' }}
  7. </view>
  8. </view>
  9. <view class="cu-form-group" style="position: relative;border-top: none">
  10. <textarea
  11. @input="textareaInput"
  12. :maxlength="maxlength"
  13. :placeholder="displayPlaceHolder"
  14. :value="value"
  15. :auto-height="autoHeight"
  16. :disabled="readonly"
  17. :enableNative="false"
  18. style="margin-top: 0; border-top: none"
  19. controlled
  20. ></textarea>
  21. </view>
  22. </view>
  23. <view v-else :class="className" :style="style" class="cu-form-group" style="position: relative;">
  24. <textarea
  25. @input="textareaInput"
  26. :maxlength="maxlength"
  27. :placeholder="displayPlaceHolder"
  28. :fixed="fixed"
  29. :value="value"
  30. :style="textareaStyle"
  31. :auto-height="autoHeight"
  32. :disabled="readonly"
  33. :enableNative="false"
  34. controlled
  35. ></textarea>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'l-textarea',
  41. props: {
  42. maxlength: { default: -1 },
  43. readonly: {},
  44. placeholder: {},
  45. fixed: {},
  46. value: {},
  47. textareaStyle: {},
  48. autoHeight: {},
  49. simpleMode: {},
  50. required: {},
  51. title: {},
  52. disabled: {}
  53. },
  54. methods: {
  55. textareaInput(e) {
  56. this.$emit('change', e.detail.value)
  57. this.$emit('input', e.detail.value)
  58. }
  59. },
  60. computed: {
  61. displayPlaceHolder() {
  62. if (this.readonly) {
  63. return ''
  64. }
  65. if (this.placeholder) {
  66. return this.placeholder
  67. }
  68. return !this.simpleMode && this.title ? `请输入${this.title}` : '请输入…'
  69. }
  70. }
  71. }
  72. </script>