Skip to content

Instantly share code, notes, and snippets.

@jean-felipe
Created May 26, 2021 11:41
Show Gist options
  • Save jean-felipe/24b1cb71a050160ebf28954ef3727015 to your computer and use it in GitHub Desktop.
Save jean-felipe/24b1cb71a050160ebf28954ef3727015 to your computer and use it in GitHub Desktop.
import Vue from 'vue';
const init = () => {
const element = document.getElementById('contacts');
if (element !== null) {
const rawData = Object.assign({}, element.dataset);
const propsData = Object.keys(rawData).reduce((acc, prop) => {
acc[prop] = parseData(rawData[prop]);
return acc;
}, {});
// eslint-disable-next-line no-new
new Vue({
el: element,
render(h) {
return h(Main, {
props: propsData,
});
},
});
}
};
['DOMContentLoaded', 'page:load', 'page:restore'].forEach((event) => {
document.addEventListener(event, init);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment