<template>
  <textarea
    v-model="inputValue"
    :placeholder="placeholder"
    placeholder-style="font-size: 26rpx;"
    :maxlength="maxlength"
    @input="handleInput"
  />
</template>

<script setup>
/** props-组件属性 */
const props = defineProps({
  // 提示语
  placeholder: {
    type: String,
    default: '请输入'
  },
  // 最大长度
  maxlength: {
    type: String,
    default: ''
  }
})
/** emits-组件事件 */
const emits = defineEmits(['update:value'])

const inputValue = ref('')

watch(() => props.value, (newVal) => {
  inputValue.value = newVal
}, { immediate: true })

// 输入时触发
const handleInput = (ev) => {
  const { value } = ev.detail
  emits('update:value', value)
}
</script>
