html输出文本,文章,识别其中的\n

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38704338/article/details/83143872

只要在结果所在的 div 的 css 设置:

white-space: pre-line;

然后页面就能成功识别 '\n' 并整齐的显示结果了。

pre{
    text-indent: .2rem;
    color: #333333;
    font-size: .28rem;
    white-space: pre-line;
}

猜你喜欢

转载自blog.csdn.net/weixin_38704338/article/details/83143872