var arr = [ { name: 'Folder 1', type: 'folder', size: '34kb', children: [ { name: 'Folder 11', type: 'folder', size: '14kb', children: [ { name: 'Folder 111', type: 'folder', size: '14kb', children: [] }, { name: 'Folder 112', type: 'folder', size: '14kb', children: [] }, { name: 'file113.png', type: 'file', size: '2kb' } ] }, { name: 'Folder 12', type: 'folder', size: '14kb', children: [] }, { name: 'Folder 13', type: 'folder', size: '14kb', children: [ { name: 'Folder 131', type: 'folder', size: '14kb', children: [] }, { name: 'Folder 132', type: 'folder', size: '14kb', children: [] }, { name: 'file133.png', type: 'file', size: '2kb' } ] } ] }, { name: 'Folder 2', type: 'folder', size: '34kb', children: [ { name: 'file21.png', type: 'file', size: '2kb' }, { name: 'file22.png', type: 'file', size: '2kb' }, { name: 'file23.png', type: 'file', size: '2kb' }, { name: 'file24.png', type: 'file', size: '2kb' } ] } ] 我需要打印出:
/** Display result:
-Folder 1 (34kb) --Folder 11 (14kb) ---Folder 111 (14kb) ---Folder 112 (14kb) -->file113.png --Folder 12 (14kb) --Folder 13 (14kb) ---Folder 131 (14kb) ---Folder 132 (14kb) -->file133.png (14kb) -folder 2 (34kb) ->file21.png (14kb) ->file22.png (14kb) ->file23.png (14kb) ->file24.png (14kb) */
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。