ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 模拟树形结构 ``` <template> <div> <ul v-for="(item,i) in list"> <li> {{item.name}} <ul v-if="item.children "> 调用自身 <item :list="item.children"></item> </ul> </li> </ul> </div> </template> ``` ``` <script> export default { name: "item",//vue2必须有name props: { list: { type: Array, default: () => { return [ { name: "item1", children: [ { name: "item2", children: [{ name: "item2.1" }] }, { name: "item3" } ] }, { name: "item4", children: [ { name: "item5" }, { name: "item6" } ] } ]; } } }, data() { return { isShow: true }; }, computed: {}, created() {}, methods: { } }; </script> ``` ![](https://img.kancloud.cn/19/8e/198eed477efdeb3b3084de13bc3c5707_439x317.png)