Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to let a multiline string returned by a function appear on multiple lines in a Vue template?

Quite straightforward but can’t get it to work.

My method returns ${a}-${b} and in my template <td>{{ myFunction() }}</td>

So right now it returns A-B in my cell. I’d like to return
A and then B on a new line. I’ve tried ${a}\n${b} or \n\ but it doesn’t seem to be working.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any suggestions ?

Thank you

>Solution :

In Vue, you are operating on HTML Template.

So you should use <br/> instead of \n

Instead of using <td>{{ myFunction() }}</td>
You may use:

<td :html="myFunction()"></td>

NOTE: you must make sure that you trust the output of myFunction to not contain malicious code (XSS Attack)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading