0
点赞
收藏
分享

微信扫一扫

MYSQL安装(ubuntu系统)

简单聊育儿 2024-11-06 阅读 15
  1. 使用<pre>标签
<pre>{{ content }}</pre>
  1. 设置white-space样式(推荐)
<div class="content">
	{{ content }}
</div>
.content{
    white-space: pre-wrap;
}
  1. 方法三:使用v-html(不推荐,可能被执行恶意脚本)

将文本中的换行与空格替换成HTML样式,然后使用v-html直接渲染HTML

<div 
    v-html="content.replace(/\n/g, '<br>').replace(/ /g, '&nbsp;')"
></div>      
举报

相关推荐

0 条评论