Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

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

over 4 years ago · Santiago Trujillo Denunciar

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>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda