ant-design-vue/components/input/demo/autosize-textarea.vue

48 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<docs>
---
order: 1
title:
zh-CN: 适应文本高度的文本域
en-US: Autosizing the height to fit the content
---
## zh-CN
属性适用于 `textarea` 节点并且只有高度会自动变化另外 `autoSize` 可以设定为一个对象指定最小行数和最大行数
> `1.5.0` `autosize` 被废弃请使用 `autoSize`
## en-US
`autoSize` prop for a `textarea` type of `Input` makes the height to automatically adjust based on the content. An options object can be provided to `autoSize` to specify the minimum and maximum number of lines the textarea will automatically adjust.
> `autosize` is deprecated after `1.5.0`, please use `autoSize`.
</docs>
<template>
<div>
<a-textarea
v-model:value="value1"
placeholder="Autosize height based on content lines"
auto-size
/>
<div style="margin: 24px 0" />
<a-textarea
v-model:value="value2"
placeholder="Autosize height with minimum and maximum number of lines"
:auto-size="{ minRows: 2, maxRows: 5 }"
/>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref<string>('');
const value2 = ref<string>('');
return {
value1,
value2,
};
},
});
</script>