I\'m super newbie in vuejs. I don\'t know how to pass props component to root instance Here is my code.
component (Tesvue.vue)
<
Here's nice solution using dataset:
HTML:
Component (Testvue.vue):
Root Instance (App.js)
const root_element = document.getElementById('app');
new Vue({
el: root_element,
propsData: { name: root_element.dataset.name }
});
See more about propsData in the docs.
If you want to use multiple dataset at once, you can assign an object using spread operator like this: (if you're using Babel and have the object-rest-spread plugin)
const root_element = document.getElementById('app');
new Vue({
el: root_element,
propsData: { ...root_element.dataset }
});
Or, simply use ES6 method if you have not used Babel: (Object.assign())
propsData: Object.assign({},root_element.dataset)
So, if you have defined multiple dataset in your html like this:
You can expose props like this:
export default {
// ...
props: ['name', 'another', 'anythingElse'],
// ...
};