Categories
Vue Answers

How to render a newline character in Vue.js?

Spread the love

Sometimes, we want to render a newline character in Vue.js.

In this article, we’ll look at how to render a newline character in Vue.js.

How to render a newline character in Vue.js?

To render a newline character in Vue.js, we add the white-space: pre CSS style.

For instance, we write

<template>
  <div id="app">
    <span style="white-space: pre">Some whitespaced content</span>
  </div>
</template>

to add the white-space: pre style to the span to render the newline characters in the span text content.

Conclusion

To render a newline character in Vue.js, we add the white-space: pre CSS style.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *