Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
How to parse \n after joining array to string in VueJS?

In my Vue.JS code I have array in object which I parsed in string like this:

destination: item[1].destination.join('\n')

In console.log(obj) I can see it looks like this:

destination: "test1\ntest3\ntest3"

But on page it looks like common string, without \n.

enter image description here

How can I parse it to make HTML see those \n?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to use style="white-space: pre-line" on your composant html

about 4 years ago · Juan Pablo Isaza Report

0

If you have an array of items then Try following the below approach

let app = new Vue({
 el: '#app',
 data() {
  return {
    textData: ['Text1\nText2\nText3', 'Text4\nText5\nText6']
  };
 },
 });
.sampleDiv {
  white-space: pre-line;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <div class="sampleDiv" v-for="(text, index) in textData" :key="index">{{text}}</div>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!