Skip to content Skip to sidebar Skip to footer

How To Initialize Vue-CLI App With Data During Created() Hook?

I am working on updating a large lecacy system, and so I am constrained by what I can and cannot do. I have a small multi-component Vue-CLI app that will replace multiple heavy jQu

Solution 1:

Perhaps you can try with props:

const mounts = document.querySelectorAll('.a-mount-spot');
for ( let i = 0; i < mounts.length; i++ ) 
{
    let mount = mounts[i];
    new Vue({
        render: h => h(App,
        {
          props:
          {
            who_am_i: mount.parentElement.dataset.myname,
          }
        })
    }).$mount(mount);
}

Post a Comment for "How To Initialize Vue-CLI App With Data During Created() Hook?"