el-textare 根据内容调整高度
时间: 2023-07-08 20:49:46 浏览: 63
可以使用 `autosize` 属性来实现根据内容自动调整高度的功能。具体实现方式如下:
1. 在 `el-textarea` 中添加 `autosize` 属性:
```html
<el-textarea v-model="content" autosize></el-textarea>
```
2. 在 Vue 组件中引入 `autosize` 库:
```javascript
import autosize from 'autosize'
```
3. 在 `mounted` 钩子函数中对 `el-textarea` 元素进行初始化:
```javascript
mounted() {
autosize(this.$refs.textarea.$refs.input)
}
```
这样就可以实现根据内容自动调整高度的功能了。
相关问题
怎么固定textare大小
要固定textarea的大小,可以使用CSS的属性来设置。可以使用width属性来设置宽度,使用height属性来设置高度。例如:
<textarea style="width: 300px; height: 150px;"></textarea>
这将把textarea的宽度设置为300像素,高度设置为150像素。你可以根据需要进行调整,来满足你的要求。
uniapp textare 怎么设置字体居中
你可以在 `textarea` 中设置 `text-align: center;` 样式来实现字体居中,示例代码如下:
```html
<template>
<textarea class="textarea" placeholder="请输入内容"></textarea>
</template>
<style>
.textarea {
width: 100%;
height: 120rpx;
font-size: 32rpx;
text-align: center;
border: none;
outline: none;
}
</style>
```
其中,`text-align` 属性用于设置文本水平居中。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)