|
|
|
|
|
by mkopinsky
2654 days ago
|
|
Or as another approach: <!-- inventory.html.twig: -->
<div
id="app"
data-inventory="{{ inventory | json_encode }}"
>
</div>
// main.js
new Vue({
template: '<App :inventory="inventory"/>',
components: {App},
data() {
return {
inventory: null
}
},
beforeMount: function () {
this.inventory = JSON.parse(this.$el.attributes['data-inventory'].value);
}
}).$mount('#app');
|
|