未定义不是函数(评估“ firebase.initializeApp(config)”)

时间:2018-12-05 05:27:09

标签: react-native

我正在尝试使用React Native触发基础连接

import * as firebase from 'firebase';

componentWillMount(){
        var config = {
         apiKey: "API_KEY",
         authDomain: "*******-****.firebaseapp.com",
         databaseURL: "https://*******-****.firebaseio.com",
         projectId: "*******-****",
         storageBucket: "*******-*****.appspot.com",
         messagingSenderId: "************",

    };
    firebase.initializeApp(config);
    console.log(firebase);
  }

如何解决此错误?

错误:

  

TypeError:undefined不是一个函数(正在评估'firebase.initializeApp(config)')

enter image description here

1 个答案:

答案 0 :(得分:1)

以类似方式导入

<?php

$str = "ABCD123456EFGH91";

$i = 0;
$arr = [];
while (1) {
    $sub_str = substr($str, $i++, 12);
    if (strlen($sub_str) !== 12) {
        break;
    }
    $arr[] = $sub_str;
}

print '<pre>';
print_r($arr);
?>

var firebase = require("firebase");