| | |
| | | /** |
| | | * CTextArea |
| | | * 多行文本输入组件,用于在表单中收集用户的多行文本输入 |
| | | * 支持设置输入区域高度,可以通过行数或像素值来控制 |
| | | * 支持只读模式和自动增高功能 |
| | | * @author Tevin |
| | | */ |
| | | |
| | | <template> |
| | | <view class="c-textarea"> |
| | | <view |
| | | class="c-textarea" |
| | | :class="readOnly?'read-only':''" |
| | | > |
| | | <AtInput |
| | | ref="input" |
| | | :name="itemRes.name" |
| | | :title="itemRes.label" |
| | | :required="itemRes.required" |
| | | :disabled="itemRes.disabled" |
| | | :error="itemRes.error" |
| | | /> |
| | | <textarea |
| | | ref="textarea" |
| | | class="textarea" |
| | | :style="{height: areaHeight}" |
| | | :style="{minHeight: areaHeight, height: areaHeight}" |
| | | :placeholder="placeholder" |
| | | :value="itemRes.formData[itemRes.name]" |
| | | :autoFocus="true" |
| | | :autoFocus="false" |
| | | :autoHeight="true" |
| | | @input="evt=>itemRes.onChange(evt.detail.value)" |
| | | /> |
| | | </view> |
| | |
| | | AtInput, |
| | | }, |
| | | props: { |
| | | // 表单数据资源(表单组件内部机制专用) |
| | | itemRes: Object, |
| | | // 文本域输入区域高度 |
| | | height: { |
| | | type: Number, |
| | | default: 94, |
| | | }, |
| | | // 文本雨输入区行数 |
| | | rows: Number, |
| | | // 只读模式 |
| | | readOnly: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | // 占位提示 |
| | | placeholder: String, |
| | | itemRes: Object, |
| | | }, |
| | | data() { |
| | | return {}; |
| | | }, |
| | | computed: { |
| | | areaHeight() { |
| | | return Taro.pxTransform(this.height); |
| | | if (this.rows) { |
| | | return Taro.pxTransform(this.rows * 40, 750); |
| | | } else { |
| | | return Taro.pxTransform(this.height, 750); |
| | | } |
| | | }, |
| | | }, |
| | | methods: {}, |