【问题标题】:ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'child' of nullERROR 错误:未捕获(承诺中):TypeError:无法读取 null 的属性“子”
【发布时间】:2017-09-01 11:08:45
【问题描述】:

我的项目一直出现此错误,因此怀疑 firebase 方面发生了一些变化,我创建了一个全新的 nativescript 项目,全新的带有全新 android 应用程序的全新 firebase 项目,添加了新的数据库数据,但仍然出现相同的错误。

基本上nativescript-plugin-firebase 插件内的所有firebase.instance 突然都为空,而我这边的代码没有任何变化

基本上nativescript-plugin-firebase 插件内的所有firebase.instance 突然都为空,而我这边的代码没有任何变化。

终端收到错误信息:

JS:firebase.addValueEventListener 中的错误:TypeError:无法读取 null JS 的属性“孩子”:错误错误:未捕获(承诺): TypeError:无法读取 null JS 的属性“子”:TypeError:不能 读取 null JS 的属性“孩子”:在 file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-plugin-firebase/firebase.js:1456:24 JS:在新的 ZoneAwarePromise (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:776:29) JS:在 Object.firebase.addValueEventListener (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/nativescript-plugin-firebase/firebase.js:1444:10) JS:在 Observable._subscribe (file:///data/data/org.nativescript.bbnsng/files/app/modules/services/firebase.service.js:23:22) JS:在 Observable._trySubscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:57:25) JS:在 Observable.subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:45:27) JS:在 Observable.ConnectableObservable.connect (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/observable/ConnectableObservable.js:37:18) JS:在 RefCountOperator.call (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/observable/ConnectableObservable.js:101:49) JS:在 Observable.subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/rxjs/Observable.js:42:22) JS:在 ObservableStrategy.createSubscription (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2664:22) JS:在 AsyncPipe._subscribe (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2778:45) JS:在 AsyncPipe.transform (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/common/bundles/common.umd.js:2755:22) JS:在 Object.eval [作为 updateDirectives] (ng:///HomeModule/HomeComponent.ngfactory.js:127:68) JS:在 Object.debugUpdateDirectives [作为 updateDirectives] (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/core/bundles/core.umd.js:12613:21) JS:在 checkAndUpdateView (file:///data/data/org.nativescript.bbnsng/files/app/tns_modules/@angular/core/bundles/core.umd.js:12025:14)

我遵循的步骤:

  • 创建一个新的仓库
  • 在 firebase 控制台中创建一个新的 firebase 项目
  • 在该 probject 下创建一个包名称为 org.nativescript.bbnsng 的 android 应用程序
  • 运行 keytool -list -v -keystore ~/.android/bbnsng.keystore 以获取 SHA1,使用相同更新应用程序
  • 向数据库添加一些数据并公开权限规则
  • 将相应的 nativescript angular 应用程序编码到此状态https://github.com/ishandutta2007/bb_ns_ng_main_app2
  • 下载google-services.json并添加到app/App_Resources/Android/
  • 运行应用程序。

复制步骤: git clone https://github.com/ishandutta2007/bb_ns_ng_main_app2.git cd bb_ns_ng_main_app2 tns run android

【问题讨论】:

    标签: angular firebase firebase-realtime-database


    【解决方案1】:

    对我来说,只要我配置了正确的 firebase 数据库,将以下语句添加到 app.js/app.ts 即可解决此问题。例如:

    require("./shared/firebase/firebase.common");
    

    对于 Angular 项目,在 main.ts 中添加 import firebase.common。例如:

    import "./shared/firebase/firebase.common";
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 1970-01-01
      • 2017-12-01
      • 2017-01-30
      • 2022-01-21
      • 1970-01-01
      • 2021-12-07
      相关资源
      最近更新 更多