Let's consider creating a Vue3 component in the following way:
import { defineComponent } from "vue";
var instance = defineComponent({
computed:{
message() {
return 'Hello world'
}
}
})
To instantiate it and add it to the DOM, we can use:
<component :is="instance"/>
But what if we want to utilize reactive properties and VueJS component features without adding it to the DOM?
Is there any method to interact with the created component instance in JavaScript without using the <component>
tag directly, like so:
console.log(instance.message) //expecting to log 'Hello World'
In Vue 2, this process was straightforward, but in Vue 3, finding a solution seems more challenging.