I've been struggling for a week now trying to understand how the Vue component work within a Twig file with x-template.
I've test my code for number of time without any luck.
new Vue ({
el: '#app',
data: function () {
return {
fname: 'John',
lname: 'Smith'
}
}
});
new Vue ({
template: '#my-template',
data: function () {
return {
fname: 'Paul',
lname: 'Smith'
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script type="text/x-template" id="my-template">
<div>Hello world</div>
<div>{{ fname }}</div>
</script>
<div id="app">
<h1>Test</h1>
<my-template></my-template>
</div>