【发布时间】:2016-11-12 10:14:32
【问题描述】:
我是 vue.js 的新手.. 我使用 webpack + vue-cli 。
但我无法将数据从父母传递给孩子
这样的代码..
<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>
顺便说一句... 如何将子组件绑定到父数组..
parent: data: array[...],
I want to bind the first of children's data to arr[0]
second to array[1]..
这可能吗?还是使用 v-for??
【问题讨论】:
-
上面的代码不起作用..我改变了父母的输入..孩子没有改变
标签: vue.js