我正在尝试通过 v-for 将多个 props 传递给一个组件 --
<my-component v-for="(myobj, myid) in mydata"></my-component>
我的数据看起来像 --
mydata: {
42: { txt: "Home", url: "https://google.com/" },
43: { txt: "SO", url: "https://stackoverflow.com/" }
}
但无法让最简单的代码段起作用 --
https://codepen.io/jerryji/pen/yGOrbj?editors=1011
任何指针将不胜感激!
最佳答案
您的 v-for
循环没有将任何数据绑定(bind)到组件。不见了v-bind
directives为您的绑定(bind)。它应该看起来像这样:
<my-component v-for="(myobj, myid) in mydata"
:myobj="myobj"
:myid="myid"></my-component>
关于javascript - Vue 组件传递多个对象作为 Prop 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53799837/