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.
 
 
 
 
 
 

59 lines
1.1 KiB

  1. <template>
  2. <view class="cu-form-group">
  3. <view class="title">
  4. <text v-if="required" class="lr-required">*</text>
  5. <slot name="title">{{ title }}</slot>
  6. </view>
  7. <input
  8. @input="input"
  9. :value="value"
  10. :type="type"
  11. :disabled="disabled"
  12. :password="password"
  13. :maxlength="maxlength"
  14. :placeholder="displayPlaceholder"
  15. :style="{ textAlign: left ? 'left' : 'right' }"
  16. />
  17. <slot name="suffix"></slot>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'l-input',
  23. props: {
  24. type: { default: 'text' },
  25. title: {},
  26. placeholder: {},
  27. maxlength: { default: -1 },
  28. disabled: {},
  29. password: {},
  30. left: {},
  31. value: {},
  32. required: {}
  33. },
  34. methods: {
  35. input(e) {
  36. this.$emit('input', e.detail.value)
  37. this.$emit('change', e.detail.value)
  38. }
  39. },
  40. computed: {
  41. displayPlaceholder() {
  42. if (this.disabled) {
  43. return ''
  44. }
  45. if (this.placeholder) {
  46. return this.placeholder
  47. }
  48. return this.title ? `请输入${this.title}` : `请输入…`
  49. }
  50. }
  51. }
  52. </script>