Ionic 3:错误消息:“预期的类型来自属性'message',该属性在此处声明为'ToastOptions'类型”

时间:2019-01-15 06:48:54

标签: ionic3

有人可以帮助我吗?

我是Ionic3的新手,我想尝试进行页面登录和注销。 我尝试使用此代码,并收到如下错误消息:

  

预期类型来自属性“ message”,该属性在此处声明为“ ToastOptions”类型

我应该如何解决这种情况?

谢谢你

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ToastController } from 'ionic-angular';
import { HomePage } from '../home/home';

import { AuthProvider } from '../../providers/auth/auth';


@IonicPage()
@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {
  credentials:any = {
      username : "",
      password : ""
  }

  constructor(public navCtrl: NavController, public navParams: NavParams, public auth:AuthProvider,public toastCtrl:ToastController) {
  }

  ionViewDidLoad() {
    let status = localStorage.getItem("isLogin");
    if (status == "true"){
      this.navCtrl.setRoot(HomePage);
    }
  }

  login()
  {
    this.auth.login(this.credentials).then((resp) => {
      let toast = this.toastCtrl.create({
        message: resp,
        duration:3000,
        position:'buttom'
      });
      toast.present();
      this.navCtrl.setRoot(HomePage);
    }).catch((err) => {
      let toast = this.toastCtrl.create({
        message: err,
        duration:2000,
        position:'buttom'
      });
      toast.present();
    })
  }

}

Fullsize image

0 个答案:

没有答案