vue 加载后台返回数据到模板 带回车符号 只需要把当前标签样式 加上white-space: pre-wrap; 再把数据用v-html 输出 就可以啦
示例:
<div class="refuse-content" v-html="item.content"></div>
<style>
.refuse-content {
width: 150px;
margin-top: 8px;
padding: 12px;
.sc(@fontsize-small, #ff5252);
line-height: 17px;
background-color: #f3f2f5;
border-radius: 4px;
overflow: hidden;
white-space: pre-wrap
}
</style>
如果实在不行 还可以用replace(/↵/g,"\n") 把换行符号转化 item.content=item.content.replace(/↵/g,"\n")