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

Time:11-26

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.

Any suggestions ?

Thank you

CodePudding user response:

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)

  • Related