Vue.js - How to print in html page a string variable (returned from a filter) that contains break line Vue.js - How to print in html page a string variable (returned from a filter) that contains break line vue.js vue.js

Vue.js - How to print in html page a string variable (returned from a filter) that contains break line


Without resorting to the terrible v-html, you can instead just apply the white-space: pre-wrap style to the span.

<span style="white-space: pre-wrap">{{ 1 | myFilter }}</span>


You can use <pre> tag for that.

For instance, when you have a string str equals to something \n new line you can write

<pre>{{ str }}</pre>

And, as expected, you'll get

something new line