我想渲染一个嵌套在另一个列表中的2个列表,但不能在嵌套的列表中使用父列表的变量。我在哪里犯错?
<v-card
v-for="n in lengthI"
.
.
<v-card
v-for="image in images.n"
我的图像对象,
images:{one:[{flex: 12, src:'https://i.ibb.co/mHNXycQ/Filler.png', title:'kuzey cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'güney cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'batı cephe'}], two:[{flex: 12, src:'https://i.ibb.co/mHNXycQ/Filler.png', title:'kuzey cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'güney cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'batı cephe'}], three:[{flex: 12, src:'https://i.ibb.co/mHNXycQ/Filler.png', title:'kuzey cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'güney cephe'}, {flex: 6, src:'https://i.ibb.co/QYvByD3/cephe.png', title:'batı cephe'}]}
最佳答案
嵌套列表非常简单,因为变量名称必须唯一,并确保为每个变量分配一个key
属性:
<v-card v-for="(n, i) in items" :key="'item' + i">
<v-card v-for="(image, k) in n.images" :key="'image' + k">
// do stuff here
</v-card>
</v-card>
希望这可以帮助。