<div class="lookText" v-if="!isAdd">{{formData.nexPlan}}</div>
<el-input
class="input_width"
v-model="formData.nexPlan"
placeholder="下周计划"
type="textarea"
:rows="2">
</el-input>
<style>
.lookText{
white-space: pre-wrap;
line-height:17px;
}
</style>
这样就可以实现在输入框中换行还有敲空格,都能显示出来了,主要使用到了css的white-space 属性
white-space 属性
normal 默认。空白会被浏览器忽略。 pre 空白会被浏览器保留。其行为方式类似 HTML 中的 <pre> 标签。 nowrap 文本不会换行,文本会在在同一行上继续,直到遇到 <br> 标签为止。 pre-wrap 保留空白符序列,但是正常地进行换行。 pre-line 合并空白符序列,但是保留换行符。 inherit 规定应该从父元素继承 white-space 属性的值。
这里我给罗列了一下,有兴趣的小伙伴们可以看一下
如果觉得对你有帮助的话,就请点赞评论加关注吧