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

122
Visualizações
Instantiate a Vue3 Component without mounting to DOM

Say i create a Vue3 component like this


import { defineComponent } from "vue";

var instance = defineComponent({
  computed:{ 
    message() {
       return 'Hello world'
    }
  }
})

I can easily instantiate it by adding it to the DOM like this:

<component :is="instance"/>

But suppose i don't want to add it to the DOM, i just want to be able to use the reactive properties and VueJS component magic.

Is there a way to create an instance of the component and interact with it in javascript without using the <component> tag like so:

console.log(instance.message) //hoping to log 'Hello World'

In Vue 2 it was easy, in Vue 3 it's like pulling teeth trying to find an answer out there.

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

0

You can use a reactive object anywhere with the composition API.

Here is an example:

https://vueschool.io/articles/vuejs-tutorials/home-rolled-store-with-the-vue-js-composition-api/

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