简体   繁体   中英

Css white-space: pre-line not working as expected

 content: string; this.content = "The system was unable to process your request.<br/>Please use your browser back button.";
 .content{ white-space: pre-line; }
 <div class="card-body text-center"> <span class="content"> {{ content }} </span> </div>

pre-line is supposed to break in
tags, instead, I get the full message including the tag. I've already tried with \n and
but nothing seems to work.

You can use template literal https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals in your typescript to pass a multi-line string. This will keep the line breaks in the text but requires to replace the <br> tag with a simple line break.

this.content = `The system was unable to process your request.
Please use your browser back button.`;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM