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

376
Visualizações
Vue 3 - how to return html from function?

I'm trying to use render functions with vue 3, and for some reasons i can't return my JSX directly in return () => [], but i need to return it from inside a function, and i was wondering if that's possible.

Here is what i'm trying to do:

const testreturn = () => {
    return h('div', { id: 'foo', innerHTML: 'hello world' }, [])
}

return () => [
    testreturn
]

If i try this, instead of seeing 'hello world' in my template, i will see the function testreturn printed out to the screen.

Instead if i try this:

return () => [
    h('div', { id: 'foo', innerHTML: 'hello world' }, [])
]

I will see a div in my template. Is there any way to accomplish what i'm trying to do in the first case?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Wouldn't it be enough to just call the function like that?

return () => [
    testreturn()
]

This is in the end the same thing as when you include the h(...) directly in the return array. Vue won't execute a function when using it inside the template.

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