我的数据:
let data = [
{
title: 1,
children: [
{
title: 1.1,
children: [
{
title: 1.3
}
]
}
]
},
{
title: 2,
children: [
{
title: 2.1,
children: [
{
title: 2.1.1,
children: [
{
title: 2.1.1.1
}
]
}
]
}
]
}
]
- 大概就像这样的数据格式,递归层级有多深,不知道..
<template v-for="item in data">
<a-sub-menu :key="item.title">
<span slot="title">
<span>{{item.title}}</span>
</span>
<template v-for="c in item.children">
<a-menu-item :key="c.title">{{c.title}}</a-menu-item>
</template>
</a-sub-menu>
</template>
- 如果还有children就要创建<a-sub-menu>,我现在只写到这写不下去了...求帮忙
vue递归主要靠组件调用自身。如:
SubMenu.vue
index.vue