院卒新人サラリーマンのメモ代わり

備忘としてのメモを記載

vuejs 子と親のデータやり取り

親から子に渡したいとき

親コンポーネント(variableを渡したい)
<child-component :from-parent="variable"></child-component>

子コンポーネント(fromParentで受け取る)
props: ['fromParent'] 

子から親に渡したいとき

子コンポーネント(variableを渡したい)
this.$emit('from-child', variable)

親コンポーネント(hogeで受け取る)
<child-component @from-child='parentMethod'></child-component>
parentMethod(data){
  this.hoge = data 
}
追記
値を受け取るだけなら
<child-component @from-child='hoge = $event'></child-component>
でいける