index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div :style="{ width: item.width ? item.width + 'px' : '100%' }">
  3. <v-textarea
  4. v-model="value"
  5. :rules="item.rules"
  6. variant="outlined"
  7. :label="item.label"
  8. :counter="item.counter"
  9. :bg-color="item.bgColor"
  10. :color="item.color || 'primary'"
  11. :validate-on="item.validateOn"
  12. :rows="item.rows || 3"
  13. :disabled="item.disabled"
  14. :density="item.dense || 'compact'"
  15. :placeholder="item.placeholder || item.label"
  16. :no-resize="!item.resize"
  17. @update:modelValue="modelValueUpDate"
  18. ></v-textarea>
  19. </div>
  20. </template>
  21. <script setup>
  22. import { defineEmits, ref, watch } from 'vue';
  23. defineOptions({ name:'FormUI-v-textarea'})
  24. const props = defineProps({item: Object, modelValue: [String, Number]})
  25. const emit = defineEmits(['update:modelValue', 'change'])
  26. const item = props.item
  27. const value = ref(props.modelValue)
  28. watch(() => props.modelValue, (newVal) => {
  29. value.value = newVal
  30. })
  31. const modelValueUpDate = (val) => {
  32. value.value = val
  33. emit('update:modelValue', value.value)
  34. emit('change', value.value)
  35. }
  36. </script>
  37. <style lang="scss" scoped>
  38. </style>