【发布时间】:2019-04-20 09:26:47
【问题描述】:
我正在尝试将数组对象传递给组件,但没有得到任何东西
创建.vue
<el-row >
<component1 v-for="product in products" :value="product" :key="product.id"></component1>
</el-row>
//脚本部分
data() {
return {
products: [] //there have (id = 1, name = first), (id = 2, name = second)
}
}
component1.vue
<el-row>
<div>
{{ product.name }}
</div>
</el-row>
export default {
props: ['value'],
watch: {
value: {
hander: function (val) {
console.log(val);
this.product = {
id: val.id,
name: val.name
}
},
deep: true
}
},
data() {
return {
product: {
id: null,
name: null
}
}
},
但手表不起作用({{product.name}} 为空),为什么?或者如何解决这个问题?
【问题讨论】:
标签: javascript vue.js webpack vuejs2 vue-component