[Vuejs]-Multiple instances of VUEjs in laravel

0👍

Notice how your vue instance mounts to an element

const app = new Vue({
    el: '#app',
});

This can be found in your app.blade.php or whatever layout you use

there will be a <div id="app"></div>

This is how you mount instances.

So now If you want a second instance

You can mount a second one to another div as long as the two divs are seperate

in app.js

const app = new Vue({
  el: '#app',
});

const app = new Vue({
  el: '#second-app',
});

Then in your app.blade.php

<div id="app"></div>
<div id="second-app"></div>

This will give you two seperate vue instances on the same page.

Leave a comment