我正在跟踪https://firebase.google.com/docs/web/setup
上的示例所以我在index.html中有这个
<body>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/6.2.4/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="https://www.gstatic.com/firebasejs/6.2.4/firebase-auth.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/6.2.4/firebase-firestore.js"></script>
<script defer src="https://www.gstatic.com/firebasejs/6.2.4/firebase-messaging.js"></script>
<!-- Initialize Firebase -->
<script src="./firebase-init.js"></script>
</body>
,这在firebase-init.js中
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: ...
authDomain: ...
databaseURL: ...
...
};
// Initialize Firebase
var app = firebase.initializeApp(firebaseConfig);
// Initialize Firestore
var db = firebase.firestore();
// also tried:
// var db = firebase.firestore(app);
// var db = app.firestore();
然而,每当我尝试加载页面时,我都会得到TypeError: firebase.firestore is not a function
这似乎很琐碎,但我无法访问Firestore
答案 0 :(得分:1)
您尝试在此处添加延期吗?
<script defer src="./init-firebase.js"></script>
根据文档,我认为您应该这样做。