1.html 识别不了 ‘\n’,只要在结果所在的标签设置css样式:

white-space: pre-line;
2.使用replace将\n替换换为标签


str.replace(/\n/g, '<br>');
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐