前端开发
774
1.递归方法实现树形结构
formatCompanyTree(data, id) { const newData = data.filter( item => item.pid == id ).map(item => ({ ...item, disabled: item.nodetype != '4', children: this.formatCompanyTree(data, item.id) })) return newData }, //data为后台请求回来的树形数据,id为树形数据的最外层节点的id
2.elementUI文件上传
uploadFile(file) { const fileData = new FormData() // 需要的参数 fileData.append('file', file.file) fileData.append('resourceType', that.resourceType) fileData.append('receiptsinfoId', that.receiptsinfoId) this.$api .uploadFile(fileData) .then(res => { if (res.code == 0) { that.$message({ type: 'success', message: '上传成功!' }) } }) },