vue 类似于百度云文件夹系统

https://img2.mukewang.com/5bfa5aeb0001d4f404100231.jpg

vue怎么实现百度云类似的文件夹系统,可以一级一级文件夹点下去,给个思路,Demo更好>_<

万千封印
浏览 2932回答 1
1回答

收到一只叮咚

每个文件夹的基础模型:class Folder {&nbsp; &nbsp; String name;&nbsp; &nbsp; Array<Folder> children;}有需要的话,也要加上个Folder Parent的指针/引用。如:var files = {&nbsp; &nbsp; name: '最顶层',&nbsp; &nbsp; children: [&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: '电影',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children: null&nbsp; &nbsp; &nbsp; &nbsp; },&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: '音乐',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children: [{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name: '杰伦',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; children: null&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }]&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ]}<script>export default {&nbsp; &nbsp; data () {&nbsp; &nbsp; &nbsp; &nbsp; currentFolder: files&nbsp; &nbsp; },&nbsp; &nbsp; methods: {&nbsp; &nbsp; &nbsp; &nbsp; next(index) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentFolder = files.children[i]&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }}</script><template>&nbsp; &nbsp; <folder-list v-if="currentFolder.children">&nbsp; &nbsp; &nbsp; &nbsp; <folder for="(f, i) in currentFolder.children" @click="nexe(i)">{f.name}</folder>&nbsp; &nbsp; </folder-list></template>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript