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

126
Views
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 answers
Answer question

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