无法阅读财产'价值'在HomePage.webpackJsonp中未定义

时间:2018-03-21 10:14:58

标签: ionic-framework ionic3

此处我正在关注此video的视频,我做了与视频相同的操作,但仍显示错误未定义的值。任何人都知道该怎么做。请帮助我,我正在使用离子3,

此处我正在关注此video的视频,我做了与视频相同的操作,但仍显示错误未定义的值。任何人都知道该怎么做。请帮助我,我正在使用离子3, home.html的



<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
 	<ion-list>
	  <ion-item>
	    <ion-label floating>Username</ion-label>
	    <ion-input type="text" name="username" ></ion-input>
	  </ion-item>

	  <ion-item>
	    <ion-label floating>Password</ion-label>
	    <ion-input type="password" name="password"></ion-input>
	  </ion-item>
	</ion-list>

     <div padding>
       <button ion-button color="primary" (click)="signIn()" block>Sign In</button>
     </div>

</ion-content>
&#13;
&#13;
&#13;

home.ts

import { Component, ViewChild } from '@angular/core';
import { NavController, AlertController  } from 'ionic-angular';

 @Component({
  selector: 'page-home',
  templateUrl: 'home.html'
 })
export class HomePage {
   @ViewChild('username') uname;
   @ViewChild('passwoed') password;

  constructor(public navCtrl: NavController, public alertCtrl: 
  AlertController ) {

  }

signIn() {
console.log(this.uname.value, this.password.value)
    if(this.uname.value == "admin" && this.password.value == "admin") {
        let alert = this.alertCtrl.create({
          title: 'Login Successfull!',
          subTitle: 'You are logged in!',
          buttons: ['OK']
        });
        alert.present();
    }
}

}

1 个答案:

答案 0 :(得分:1)

你在home.html上犯了错误,我解决了这个问题。

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-list>
    <ion-item>
      <ion-label floating>Username</ion-label>
      <ion-input type="text" #username ></ion-input>
    </ion-item>

    <ion-item>
      <ion-label floating>Password</ion-label>
      <ion-input type="password" #password></ion-input>
    </ion-item>

  </ion-list>

  <div padding>
    <button ion-button color="primary" (click)="signIn()" block>Sign In</button>
  </div>

</ion-content>