Created
May 26, 2021 11:41
-
-
Save jean-felipe/24b1cb71a050160ebf28954ef3727015 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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