Javascript 错误:未捕获(承诺中)TypeError:\u this2.next不是reactJS中的函数

Javascript 错误:未捕获(承诺中)TypeError:\u this2.next不是reactJS中的函数,javascript,reactjs,ecmascript-6,Javascript,Reactjs,Ecmascript 6,我收到了这个错误,你能帮我删除这个错误吗。我的申请中有4个案例。在案例1中,您可以查看我的步骤2代码。请帮帮我,我真的卡住了 case 1: // code run for step 2 const reader = new FileReader(); const storeUser = JSON.parse(localStorage.getItem('user')); reader.onload = function(uploa

我收到了这个错误,你能帮我删除这个错误吗。我的申请中有4个案例。在案例1中,您可以查看我的步骤2代码。请帮帮我,我真的卡住了

case 1:
        // code run for step 2

        const reader = new FileReader();
        const storeUser = JSON.parse(localStorage.getItem('user'));
        reader.onload = function(upload) {
          fetch(`...../api/s3/uploadtoaws`, {
            headers: {
              Accept: 'application/json',
              'Content-Type': 'application/json',
            },
            method: 'POST',
            body: JSON.stringify({
              userId: storeUser._id,
              type: 'employee',
              content: upload.target.result,
              key: 'e.file.name',
              oldKey: '',
            }),
          })
            .then(response => response.json())
            .then(res => {
              if (res.error) {
                console.warn(res);
              } else {
                console.warn(res);
                this.next();
              }
            })
            .done();
        };
        reader.readAsDataURL(values.picture.file.originFileObj);
        break;
reader.onload=函数上传{

由于这是一个普通函数,它的值由它的调用方式决定。我假设FileReader在非严格模式下调用它时,它等于全局对象,或者在严格模式下是未定义的。虽然我不确定FileReader代码是如何实现的,但它可以等于其他对象,例如文件读取器itself、 不管怎样,稍后当你称之为“下一步”时,这并不等于你所认为的

如果将其更改为箭头函数,它将从其定义的位置获取其值

reader.onload = (upload) => {
请注意,这可能还不够,因为这还取决于您提供的示例周围的代码