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

123
Vistas
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 Respuestas
Responde la pregunta

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 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