html页面填入字符串,\n换行不起作用,空格不保留,怎么办?

CSS white-space 属性

html页面填入字符串,\n换行不起作用,空格不保留,怎么办?
html页面填入字符串,\n换行不起作用,空格不保留,怎么办?
在white-space属性中,有上图几个值可供选择,我们可以在DOM元素中使用white-space: pre-wrap;
这样在html页面填入字符串,\n换行和空格就起作用了。