vue 树状的数据怎么v-for渲染?

数据层级有很多层,也不能确定几层,请问怎么渲染出来呢,谢谢?

<div v-for="(item, index) in data">
    <div class="name">{{item.name}}</div>
    <div class="children" v-for="(itemSon, index) in item.children">
        <div class="name">{{itemSon.name}}</div>
        ...
        ...
        ...
    </div>
</div>

data = [
  {
    name: "About",
    path: "/about",
    children: [
      {
        name: "About US",
        path: "/about/us"
      },
      {
        name: "About Comp",
        path: "/about/company",
        children: [
          {
            name: "About Comp A",
            path: "/about/company/A",
            children: [
              {
                name: "About Comp A 1",
                path: "/about/company/A/1"
              }
            ]
          }
        ]
      }
    ]
  },
  {
    name: "Link",
    path: "/link"
  }
];


阅读 1.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题