index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 || 200"
  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. :clearable="item.clearable || false"
  18. clear-icon="mdi-close-circle"
  19. @update:modelValue="modelValueUpDate"
  20. ></v-textarea>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, watch } from 'vue';
  25. defineOptions({ name:'FormUI-v-textarea'})
  26. const props = defineProps({item: Object, modelValue: [String, Number]})
  27. const emit = defineEmits(['update:modelValue', 'change'])
  28. const item = props.item
  29. const value = ref(props.modelValue)
  30. watch(() => props.modelValue, (newVal) => {
  31. value.value = newVal
  32. })
  33. const modelValueUpDate = (val) => {
  34. value.value = val
  35. emit('update:modelValue', value.value)
  36. emit('change', value.value)
  37. }
  38. </script>
  39. <style lang="scss" scoped>
  40. </style>