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

223
Views
Cómo mostrar una variable que se inyecta en un archivo json en Vue

Tengo un archivo JSON y estoy usando su contenido para representar dinámicamente el texto dentro de un cuadro. El contenido del cuadro cambia cuando la página se monta por primera vez y al pasar el mouse sobre algunos botones, etc. en la página.

El problema es que el texto en JSON también puede ser dinámico. Por ejemplo:

 . . . "tips": { "home": { "general": "Welcome to ${testPage}"!, "button1": "Click this button to log in." } } . . .

La plantilla de Vue es así (también puede haber código HTML en el texto JSON, así que uso v-html):

 <div v-html="tips.home.general"></div>

También lo intenté así, no funcionó:

 <div>{{tips.home.general}}</div>

Y la variable testPage se define así en el componente por ahora (más tarde, será un valor dinámico que obtendré del backend):

 data: () => ({ testPage: 'test demo page name' })

Todo funciona muy bien, excepto que no puedo hacer que Vue lea esta variable "testPage" como una variable. Simplemente representa el texto "${testPage}".

Resolví este problema antes en JSP simplemente agregando el nombre de la variable en JSON como <%= testPage %>, pero un enfoque similar no funciona aquí.

¿Hay alguna manera de que se pueda hacer en Vue?

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