2016-07-10 12 views
0

私はvue.jsで新しいです。 私はwebpack + vue-cliを使用しています。vue.jsでデータを渡すことができません

しかし、私はこのように親から子へ

コードをデータを渡すことはできません。..

<template lang="html"> 
 
    <div> 
 
    <input v-model="parentMsg"></input> 
 
    <br> 
 
    <child v-bind:msg="parentMsg"></child> 
 
    </div> 
 
</template> 
 

 
<script> 
 
import child from './components/lists' 
 
export default { 
 
    data: function() { 
 
    return { 
 
     parentMsg: '' 
 
    } 
 
    }, 
 
    computed: {}, 
 
    ready: function() {}, 
 
    attached: function() {}, 
 
    methods: {}, 
 
    components: { 
 
    child 
 
    } 
 
} 
 
</script>

<template> 
 
    <div> 
 
    {{msg}} 
 
    </div> 
 
</template> 
 

 
<script> 
 
export default { 
 
    data: function() { 
 
    return { 
 
     msg: '' 
 
    } 
 
    } 
 
} 
 
</script>

をワシントン州ではyは... はどのように

parent: data: array[...], 
I want to bind the first of children's data to arr[0] 
second to array[1].. 

これは可能..です親配列に子コンポーネントをバインドするには?またはv-forを使用しますか?あなたの子コンポーネントで

+0

上記のコードの詳細を読む

<script> export default { props: ['msg'], data: function() { return { } } } </script> 

は親で入力を変更work..Iない..です子変わらない – Loatheb

答えて

0

のように親データを受信するpropsプロパティを使用します。このhere

関連する問題