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

284
Vistas
Why vhtml not rendering nested << properly?

I have an app that uses dynamic binding where <> is a dynamic way of getting value from API. But when I am trying to render it in vhtml, its not even showing the parent element. I want it like Name: <<Name>>. How this can be achieved? . I have attached the example code.

const app = new Vue({
  el: '#app',
  data () {
    return {
      htmlText: '<p> Name : <<Name>> </p>'
    }
   }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<span v-html="htmlText"></span>
</div>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

On top of Link's and Xlm's answers on vue: escape and render HTML string?

Parse the incoming string with a regex that replaces < with &lt; and > with &gt;

Please note that this could be just a workaround. If you want a cleaner solution, you should do this in the API.

In your case,

 const app = new Vue({
   el: "#app",
   data() {
      return {
        htmlText: "<p> Name : <<Name>> </p>",
      };
   },
   methods: {
      htmlToText(html) {
          return html.replace(/<</g, "&lt;&lt;").replace(/>>/g, "&gt;&gt;");
      },
   },
});
<div id="app">
  <span v-html="htmlToText(htmlText)"></span>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

about 4 years ago · Juan Pablo Isaza 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