gpt4 book ai didi

typescript - 'loading' 类型不存在属性 'SignupPage' (TypeScript)

转载 作者:行者123 更新时间:2023-12-04 03:16:46 25 4
gpt4 key购买 nike

你好来自stackoverflow的好家伙!

我是 MEAN 堆栈的新手,并且仍在尝试了解它的基础知识。

我正在尝试进行简单的身份验证。这是代码:

import { Component } from '@angular/core';
import { NavController, LoadingController } from 'ionic-angular';
import { Auth } from '../../providers/auth';
import { HomePage } from '../home/home';

@Component({
selector: 'signup-page',
templateUrl: 'signup-page.html'
})
export class SignupPage {

role: string;
email: string;
password: string;

constructor(public navCtrl: NavController, public authService: Auth, public loadingCtrl: LoadingController) {

}

register(){

this.showLoader();

let details = {
email: this.email,
password: this.password,
role: this.role
};

this.authService.createAccount(details).then((result) => {
this.loading.dismiss();
console.log(result);
this.navCtrl.setRoot(HomePage);
}, (err) => {
this.loading.dismiss();
});

}

showLoader(){

this.loading = this.loadingCtrl.create({
content: 'Authenticating...'
});

this.loading.present();

}

}

这是我得到的错误:
[12:43:17]  typescript: src/pages/signup-page/signup-page.ts, line: 31 
Property 'loading' does not exist on type 'SignupPage'.

L30: this.authService.createAccount(details).then((result) => {
L31: this.loading.dismiss();
L32: console.log(result);

[12:43:17] typescript: src/pages/signup-page/signup-page.ts, line: 35
Property 'loading' does not exist on type 'SignupPage'.

L34: }, (err) => {
L35: this.loading.dismiss();
L36: });

[12:43:17] typescript: src/pages/signup-page/signup-page.ts, line: 42
Property 'loading' does not exist on type 'SignupPage'.

L42: this.loading = this.loadingCtrl.create({
L43: content: 'Authenticating...'

[12:43:17] typescript: src/pages/signup-page/signup-page.ts, line: 46
Property 'loading' does not exist on type 'SignupPage'.

L46: this.loading.present();

[12:43:17] transpile failed

任何人都可以澄清我缺少什么以及我应该学习什么才能继续我的项目?

最佳答案

试试这个...

export class SignupPage {

role: string;
email: string;
password: string;
loading: any;

constructor(public navCtrl: NavController, public authService: Auth, public loadingCtrl: LoadingController) {

}
....
}

关于typescript - 'loading' 类型不存在属性 'SignupPage' (TypeScript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40362664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com