textarea.vue 874 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <div class="k-textarea">
  3. <el-input
  4. type="textarea"
  5. :rows="row"
  6. v-model="pv"
  7. :maxlength="length"
  8. :disabled="disabled"
  9. :placeholder="placeholder"
  10. ></el-input>
  11. <div class="k-textarea__length">{{ pv ? pv.length : 0 }} / {{ length }}</div>
  12. </div>
  13. </template>
  14. <script>
  15. import sync from "../utils/computed.sync";
  16. export default {
  17. data() {
  18. return {};
  19. },
  20. computed: {
  21. pv: sync("value")
  22. },
  23. watch: {},
  24. props: {
  25. value: {},
  26. disabled: {
  27. type: Boolean,
  28. default: false,
  29. },
  30. row: {
  31. type: Number,
  32. default: 5,
  33. },
  34. length: {},
  35. placeholder: {}
  36. },
  37. methods: {},
  38. mounted() {
  39. }
  40. };
  41. </script>
  42. <style lang="scss">
  43. .k-textarea {
  44. position: relative;
  45. &__length {
  46. position: absolute;
  47. bottom: -25px;
  48. right: 12px;
  49. font-size: 12px;
  50. }
  51. }
  52. </style>