当前位置: 移动技术网 > IT编程>脚本编程>vue.js > vue-for循环嵌套操作示例

vue-for循环嵌套操作示例

2019年05月28日  | 移动技术网IT编程  | 我要评论

华中科技大学就业网,前四后八自卸车报价,你的承诺 歌词

本文实例讲述了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代码运行工具:测试上述代码,可得如下运行结果:

希望本文所述对大家vue.js程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网