Reputation: 1331
Data can be passed down to child components using props. But why doesn't my tag child work?It doesn't print out hello.Here is my code, html:
<div id="app">
<child message="hello"></child>
</div>
javascript:
new Vue({
el:'#app'
});
Vue.component('child',{
props:['message'],
template:"<span>{{message}}</span>"
})
Upvotes: 0
Views: 56
Reputation: 32704
You component needs to be declared before your main Vue instance:
Vue.component('child',{
props:['message'],
template:"<span>{{message}}</span>"
})
new Vue({
el:'#app'
});
Here's the JSFiddle: https://jsfiddle.net/Lxeb7gmo/
Upvotes: 1
Reputation: 2434
You must dynamically bind it by adding : in front of message like this
:message="hello"
Upvotes: 0