// 是否存在上传中 let isUploading = false function broadcast(componentName, eventName, params) { this.$children.forEach(child => { var name = child.$options.name if (name === componentName) { console.log('child.uploadFiles', child.uploadFiles) if (child.uploadFiles && child.uploadFiles.length > 0) { child.uploadFiles.forEach((item) => { if (item.status && item.status === 'uploading') { isUploading = true return } }) } } else { broadcast.apply(child, [componentName, eventName].concat([params])) } }) } export default { methods: { // 是否存在上传中文件 isUploading(componentName = 'ElUpload', eventName, params) { isUploading = false broadcast.call(this, componentName, eventName, params) return new Promise((resolve) => { if (isUploading) { this.$confirm('您确认要放弃未完成的文件上传吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { resolve(true) }).catch(() => { resolve(false) }) } else { resolve(true) } }) } } }
标签:ElementUi,componentName,Upload,传中,eventName,params,isUploading,child,uploadFiles From: https://www.cnblogs.com/zerofan/p/16919662.html