啊,小雪,小雪,来了,来了。从微微的凉风中,从傍晚的喧闹中来了!像春风抖落万树梨花,像天女撒下漫天白絮……你不飘飘悠悠,因为那是骄傲的象征;你不轻轻起舞,因为那是胆小的缩影,听,沙沙沙沙、沙沙沙沙……我好像坐在屋里听那春雨的歌声。
本文实例讲述了vue-for循环嵌套操作。分享给大家供大家参考,具体如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ margin: 0; padding: 0; list-style: none; } </style> </head> <body> <table id="app" border="1" cellspacing="0" cellpadding="0"> <tr> <td>父循环第几次</td> <td>子循环第几次</td> <td>json的第几条数据</td> <td>数值</td></tr> <tbody v-for="x,index in parentList"> <tr v-for="i,index2 in x.childList"> <td>{{index}}</td> <td>{{index2}}</td> <td>{{i.index}}</td> <td>{{i.childName}}</td> </tr> </tbody> </table> </body> <script src="https://cdn.bootcss.com/vue/2.4.4/vue.min.js"></script> <script> const app=new Vue({ el:"#app", data:{ parentList: [{ childList: [{ index: 1, childName: "第一个节点" }, { index: 2, childName: "第一个节点" }, { index: 3, childName: "第一个节点" }, { index: 4, childName: "第一个节点" }, { index: 5, childName: "第一个节点" }] }, { childList: [{ index: 6, childName: "第二个节点" }, { index: 7, childName: "第二个节点" }, { index: 8, childName: "第二个节点" }, { index: 9, childName: "第二个节点" }, { index: 10, childName: "第二个节点" }] }, { childList: [{ index: 11, childName: "第三个节点" }, { index: 12, childName: "第三个节点" }, { index: 13, childName: "第三个节点" }, { index: 14, childName: "第三个节点" }, { index: 15, childName: "第三个节点" }] }] } }) </script> </html>
这里使用在线HTML/CSS/JavaScript代码运行工具:http://tools.haodaima.com/code/HtmlJsRun测试上述代码,可得如下运行结果:
希望本文所述对大家vue.js程序设计有所帮助。
到此这篇关于vue-for循环嵌套操作示例就介绍到这了。笑看人生峰高处,唯有磨难多正果。更多相关vue-for循环嵌套操作示例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!