我从 JSON 文件中获取以下原始字符串。我 console.log 它显示正常。
"Hello, my name is Jane, from "IStaff" company.\r\n\r\n.We are interested in your service.\r\n\r\n.Please call me back "
当我渲染此字符串时,没有新行。
最佳答案
就我而言,最好的方法就是在 css 中添加:white-space: pre-wrap;
关于javascript - 如何在 JSON 字符串中用 <br> 替换\n?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55274459/