平时在开发中遇到上传需求,可能会使用到webuploader,但是需求现状可能是,在上传的传参需要先从后台获取数据,这时候解决方案参考如下,如果封装多次调用的话,需要先unRegister
WebUploader.Uploader.unRegister('contractUpload') WebUploader.Uploader.register({ name: 'contractUpload', 'before-send-file': 'doSomthingAsync' }, { doSomthingAsync: function() { if (that.module === 1 && that.mkey === '-1') { var deferred = WebUploader.Deferred(); axios.post({}).then((res) => { //更改实例化传入的参数,逻辑省略 deferred.resolve() }) return deferred.promise(); } } });