javascript">
<template><div><el-treeref="tree"v-loading="treeData.loading":data="treeData.data"node-key="id" :props="defaultProps":render-content="renderTreeNode"></el-tree></div>
</template><script>
export default {data() {return {treeData: {loading: false,data: [{id: 1,name: '文件1',fileSize: 391055,fileCount: 1,children: []},]},defaultProps: {children: 'children',label: 'name' }};},methods: {renderTreeNode (h, { node, data, store }) {const fileSizeDisplay = this.safeFormatFileSize(data.fileSize);const fileCountDisplay = data.fileCount || '0';return h('span', [h('span', data.name),h('span', { style: { marginLeft: '2px', color: '#ccc' } }, `(${'大小'}:${fileSizeDisplay}, ${'数量'}:${fileCountDisplay})`)]);},safeFormatFileSize (val) {const safeBytes = val ? val : 0;return this.formatFileSize(safeBytes);},formatFileSize (bytes) {if (bytes === 0) return '0B';const sizes = ['B', 'KB', 'MB', 'GB'];let i = 0;while (bytes >= 1024 && i < sizes.length - 1) {bytes /= 1024;i++;}return `${bytes.toFixed(2)}${sizes[i]}`;},}
};
</script><style scoped></style>