后端传的json数据
{
code:200,
list:[
{
type:1,
path:'www.file.xxxxx',
name:'xx',
suffix: ,
parentid:123
...
},
{
type:2,
path:'www.file.xxxxx',
name:'zzz',
suffix: ".xlsx",
parentid: null
...
}
...
]
}
type 1为文件夹 2为文件(文件可能是pdf,png,wrod)
<scroll-view class='fmm-contont' scroll-y='true'>
<block wx:for="{{files}}" wx:for-item="file" wx:key="*this" >
<view class='file-item' data-id='{{file.id}}' catchtap='onFileTap' wx:if="{{file.type != 1}}">
<text>{{file.fileName}}</text>
</view>
<view wx:else>
<view class='floder-item' data-id='{{file.parentid}}' catchtap='onFloderTap'>
<text>{{file.fileName}}</text>
</view>
...
</view>
</block>
</scroll-view>
这个接口返回第一层级的文件和文件夹可以遍历出来,点击文件夹给这个接口传一个parentid可以获取到第二个层级的数据,但是wxml我该如何去遍历呢?给.floder-item下边再写一个wx:for="{{childfiles}}"吗?如果底下还有第三第四级怎么办?没有一点思路
递归遍历获取