WoJ WoJ - 6 months ago 39
Javascript Question

How to pass data to a child component?

I am learning

and the answer to my question is in the documentation for dynamic props. I however fail to have in working in practice for my data structure.

My intent is to have a custom component
fed with data from the

Vue.component('cell', {
props: cell,
template: '<div>day is {{ cell.name }}</div>'

new Vue({
el: '#container',
data: {
"week": {
"today": {
"name": "Monday"
"tomorrow": {
"name": "Tuesday"

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>

<div id="container">
<cell v-bind:cell="week.today"></cell>
<cell v-bind:cell="week.tomorrow"></cell>

(this snippet does not run at all, not sure if vue.js is supported. I also have a JSFiddle to test on)

The expected result is

<div>day is Monday</div>
<div>day is Tuesday</div>

The output is empty, so I believe that there is something fundamentally wrong with my code. What is it?


props must be an array or object, so basically:

props: ['cell']


props: {
   cell: {
     // options

but not:

props: cell

I've fixed the fiddle for you here: