You could just check if the element is on the page:
if (document.getElementById('root1')) {
const app1 = new Vue({ el: '#root1' })
}
Hi, I'm migrating a big e-commerce application to Vue and I have some questions. The current code base has lots of js in line code, a mix of libs (jQuery and PrototypeJS). I'll move everything to Vue and ES6 but, til then I need to keep the things working and adding Vue step by step.
So, I now that I can create multiple instances pointing to multiple root elements. But, what to do in cases when I don't have the element in a particular page? Vue is throwing a warning in such cases. This is a big problem or I can live with that?
Is it possible to run Vue components without binding the new Vue() to a root element?
Thanks :-;
You could just check if the element is on the page:
if (document.getElementById('root1')) {
const app1 = new Vue({ el: '#root1' })
}
Please or to participate in this conversation.