我正在尝试通过v-for将多个道具传递给组件-
<my-component v-for="(myobj, myid) in mydata"></my-component>
mydata看起来像-
mydata: {
42: { txt: "Home", url: "https://google.com/" },
43: { txt: "SO", url: "https://stackoverflow.com/" }
}
但是无法获得最简单的代码片段-
https://codepen.io/jerryji/pen/yGOrbj?editors=1011
任何指针将不胜感激!
答案 0 :(得分:4)
您的v-for
循环未将任何数据绑定到组件。您的绑定缺少v-bind
directives。它应该看起来像这样:
<my-component v-for="(myobj, myid) in mydata"
:myobj="myobj"
:myid="myid"></my-component>