【发布时间】:2022-01-18 02:08:18
【问题描述】:
我找到了this 项目。在我添加到index.html 文件后,下面的 Firebase 配置:
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-auth.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-firestore.js";
import { initializeApp } from "https://www.gstatic.com/firebasejs/8.6.1/firebase-storage.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDoO8efzrDVveeXvqqrc39D3XiqfsyoKeU",
authDomain: "diary-app-course-c6663.firebaseapp.com",
projectId: "diary-app-course-c6663",
storageBucket: "diary-app-course-c6663.appspot.com",
messagingSenderId: "1031493909898",
appId: "1:1031493909898:web:3cd71413645447b67c1c73"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
</script>
不幸的是,我收到以下错误:
Launching lib/main.dart on Chrome in debug mode...
lib/main.dart:1
This app is linked to the debug service: ws://127.0.0.1:33579/wuKO980VWbQ%3D/ws
Debug service listening on ws://127.0.0.1:33579/wuKO980VWbQ=/ws
???? Running with sound null safety ????
Connecting to VM Service at ws://127.0.0.1:33579/wuKO980VWbQ=/ws
Error: [core/not-initialized] Firebase has not been correctly initialized. Have you added the Firebase import scripts to your index.html file?
View the Web Installation documentation for more information: https://firebase.flutter.dev/docs/installation/web
at Object.throw_ [as throw] (http://localhost:43973/dart_sdk.js:5061:11)
at http://localhost:43973/packages/firebase_core_web/firebase_core_web.dart.lib.js:90:29
at initializeApp (http://localhost:43973/packages/firebase_core_web/firebase_core_web.dart.lib.js:96:29)
at initializeApp.next (<anonymous>)
at runBody (http://localhost:43973/dart_sdk.js:38659:34)
at Object._async [as async] (http://localhost:43973/dart_sdk.js:38690:7)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:43973/packages/firebase_core_web/firebase_core_web.dart.lib.js:78:20)
at initializeApp (http://localhost:43973/packages/firebase_core/firebase_core.dart.lib.js:94:59)
at initializeApp.next (<anonymous>)
我错过了什么?
【问题讨论】:
标签: firebase flutter flutter-web