错误TS2339:类型“ UserCredential”上不存在属性“ sendemailverification”

时间:2018-12-09 00:31:58

标签: typescript angular-cli-v6

我收到此错误:

error TS2339: Property 'sendemailverification' does not exist on type 'UserCredential'

这是我的代码 我正在使用Firebase电子邮件验证

import { Component, OnInit } from '@angular/core';
import {NgForm} from '@angular/forms';
import * as firebase from 'firebase/app';

@Component({
  selector: 'app-sign-up',
  templateUrl: './sign-up.component.html',
 styleUrls: ['./sign-up.component.css']
})
export class SignUpComponent implements OnInit {

  constructor() { }

  ngOnInit() {
}

onSubmit(form: NgForm) {
const fullname = form.value.fullname;
const email = form.value.email;
const password = form.value.password;

firebase.auth().createUserWithEmailAndPassword(email, password)
  .then(userData => {
    //error
    userData.sendemailverification();
    console.log(userData);
  })
  .catch(err =>{
    console.log(err);
  });
  }

}

2 个答案:

答案 0 :(得分:0)

正确的方法是sendEmailVerification而不是sendemailverification

答案 1 :(得分:0)

您可以使用 userData.user.sendEmailVerification()使其正常工作。