【发布时间】:2016-11-01 18:50:39
【问题描述】:
希望有人能帮忙,把我的头发拉出来一点。
我正在开发一个带有 Firebase 3 后端的应用程序 Ionic 2。在浏览器中本地测试时效果很好,即当我运行命令时:
ionic serve
我之前将它安装到我的 IOS 设备上没有问题,但是我现在在尝试构建时不断收到以下错误:
myIonicFFApp $ ionic build ios
Running 'build:before' npm script before build
> Feetfirst@ build /Users/alan/Desktop/myIonicFFApp
> ionic-app-scripts build
[10:38:00] ionic-app-scripts 0.0.37
[10:38:00] build prod started ...
[10:38:00] clean started ...
[10:38:00] clean finished in 3 ms
[10:38:00] copy started ...
[10:38:00] ngc started ...
[10:38:01] copy finished in 109 ms
[10:38:01] lint started ...
[10:38:03] lint finished in 1.90 s
[10:38:13] Error: Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:437:40
[10:38:13] Property 'infantName' does not exist on type 'InfantCreatePage'.
[10:38:13] Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:467:41
[10:38:13] Property 'infantDate' does not exist on type 'InfantCreatePage'.
[10:38:13] Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:603:43
[10:38:13] Property 'infantName' does not exist on type 'InfantCreatePage'.
[10:38:13] Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:608:43
[10:38:13] Property 'infantDate' does not exist on type 'InfantCreatePage'.
[10:38:13] Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:623:68
[10:38:13] Property 'infantName' does not exist on type 'InfantCreatePage'.
[10:38:13] Error at /Users/alan/Desktop/myIonicFFApp/.tmp/pages/infant-create/infant-create.ngfactory.ts:623:92
[10:38:13] Property 'infantDate' does not exist on type 'InfantCreatePage'.
[10:38:13] ngc failed
[10:38:13] ionic-app-script task: "build"
[10:38:13] Error: Error
npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v4.4.5
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! Feetfirst@ build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Feetfirst@ build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the Feetfirst package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm
ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs Feetfirst
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls Feetfirst
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/alan/Desktop/myIonicFFApp/npm-debug.log
Caught exception:
undefined
有什么可能导致这种情况的想法吗?
Below is my: infant-create.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { InfantData } from '../../providers/infant-data';
@Component({
selector: 'page-infant-create',
templateUrl: 'infant-create.html',
})
export class InfantCreatePage {
public nav: NavController; // <- Declare the property explicitly.
public infantData: InfantData; // <- Declare the property explicitly.
constructor( nav: NavController, infantData: InfantData) {
this.nav = nav;
this.infantData = infantData;
}
createInfant(infantName: string, infantDate: string) {
this.infantData.createInfant(infantName, infantDate).then( () => {
this.nav.pop();
});
}
}
其中引用了 infant-data.ts:
import { Injectable } from '@angular/core';
import firebase from 'firebase';
@Injectable()
export class InfantData {
public currentUser: any;
public infantList: any;
public profilePictureRef: any;
constructor() {
this.currentUser = firebase.auth().currentUser.uid;
this.infantList = firebase.database().ref('userProfile/' + this.currentUser + '/infantList');
this.profilePictureRef = firebase.storage().ref('/guestProfile/');
}
getInfantList(): any {
return this.infantList;
}
getInfantDetail(infantId): any {
return this.infantList.child(infantId);
}
createInfant(infantName: string, infantDate: string): any {
return this.infantList.push({
name: infantName,
date: infantDate
}).then( newInfant => {
this.infantList.child(newInfant.key).child('id').set(newInfant.key);
});
}
}
【问题讨论】:
-
您的
InfantCreatePage中似乎使用了一个名为infantDate的属性,但该属性未在组件代码中定义。 -
是的,看起来就是这样,但我是……
-
...我已更新帖子以包含相关代码?...谢谢!