为什么 onSubmit 中的方法调用会抛出错误?

Why Method call inside onSubmit throws error?

我尝试调用 metetor 方法,但它抛出错误 "Uncaught TypeError: Meteor.call is not a function" 但是当我尝试在 imports/api/some.js 中的另一个文件中调用相同方法时,这有效,这意味着调用代码是正确的,但是它在 onSubmit 内部工作,为什么?这里是githuburl

文件:imports/ui/otp.js

onSubmit(e) {
  e.preventDefault();

  let otp = this.refs.otp.value.trim();

  Meteor.call('find-otp', otp, (error, result) => {
    if(error) {
      console.log('otp error check', error);
    } else {
      console.log('otp res check', result);
    }
   });
}

文件:imports/api/db.js

   Meteor.methods({
    'find-otp' (otp) {
        // if(!this.userId) {
        //     throw new Meteor.Error('not-authorized');
        //  }
         console.log('otpcheck', otp);
         return true;
        //  return otp; // also I try this
    }
});

确保正确导入 Meteor:

import { Meteor } from 'meteor/meteor'