<?php
$data = json_decode(['name' => 'John']);
?>
<div id="simple-component">
<simple-component :data-state='<?php echo json_encode($data)?>'></simple-component>
</div>
Vue.component('simple-component', {
template: '<div>{{state.name}}</div>',
props: {
dataState: {
type: Object,
required: true
},
data() {
return {
state: this.dataState
};
}
}
})
new Vue({
el: '#simple-component',
})
{
template: `
<div>
<preloader v-if="!pageData" />
<div v-else >
...
</div>
</div>
`,
data() {
return {
pageData: null
}
},
async mounted() {
this.pageData = await getData()
}
}