[Vue.js]親から子へデータを渡す


html

<div id="app">
   <hello message="come on!!!"></hello>
</div>

vue.js

Vue.component('hello',{
  props:['message'],
  template:'<p>{{message}}</p>',
})  


var app = new Vue({
  el:'#app',
})

ブラウザ

come on!!!

もっと直感的に書けるのがslot

html

<div id="app">
   <hello>
     うわああああああああああああああああああああああああああああああああ
   </hello>
</div>

Vue.js

Vue.component('hello',{
  template:'<p><slot></slot></p>',
})  


var app = new Vue({
  el:'#app',
})

ブラウザ

うわああああああああああああああああああああああああああああああああ