更新时间:2023-12-04 14:02:16
您应该将 \ n
替换为< br>
,因为 innerHTML
接受一个HTML字符串(在HTML中, \ n
与相邻空格合并,但除了样式 white-space:预包装,如MaxArt所述):
You should replace \n
by <br>
since innerHTML
takes an HTML string (in HTML, \n
merges with adjacent spaces but does not produce a carriage return except for elements with the style white-space:pre-wrap
as noted by MaxArt) :
document.getElementById("overlaycontent").innerHTML = (
StringContent.a + '<br>' +
StringContent.b + '<br>' +
StringContent.c,
)