后台数据返回值带换行符,前端展示
2021-10-25 本文已影响0人
Moment929
第一种方法:
前端获取后台带有\n 换行符的数据
用<pre></pre> 标签展示
<pre>{{errorDetail}}</pre>
dialogError(val) {
this.dialogVisible = true
this.errorDetail = val
}
第二种方法
前端获取后台带有\n 换行符的数据,转成·<·br·/>·
通过v-html 展示
<span v-html="errorDetail"></span>
dialogError(val) {
this.dialogVisible = true
this.errorDetail = val.replace(/\n/g,"<br/>")
}
可以实现展示换行的效果