Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

228
Visualizações
How to display a variable that is injected in json file in Vue

I have a JSON file and I'm using its content to dynamically render the text inside a box. The content of the box changes when the page is first mounted, and with hover over some buttons, etc. in the page.

The problem is, the text in the JSON can also be dynamic. For example:

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

The Vue template is like this (there can also be HTML code in the JSON text, so I use v-html):

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

Also tried like this, didn't work:

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

And the testPage variable is defined like this in the component for now (later, it will be a dynamic value I'll get from the backend):

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

Everything works great, except I can't get Vue to read this "testPage" variable as a variable. It just renders the text "${testPage}".

I solved this problem before in JSP by just adding the variable name in JSON like <%= testPage %>, but a similar approach doesn't work here.

Is there a way that it can be done in Vue?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda