我正在撰写一个包含Nuxt.js
和Firebase
的网络应用。我需要在哪个文件中初始化Firebase
?换句话说,在哪里放置此代码片段?
var config = {
apiKey: "xxxxxxxxxx",
authDomain: "xxxxxxxxx.firebaseapp.com",
databaseURL: "https://xxxxxxxx.firebaseio.com",
projectId: "xxxxxxxxx",
storageBucket: "xxxxxxxxxxx.appspot.com",
messagingSenderId: "xxxxxxxxxx"
};
firebase.initializeApp(config);
答案 0 :(得分:10)
在文件夹{ "00:00" :[
[{"id":1, time: "00:05"}, {"id":2, time: "00:05"}, {"id":3, time: "00:05"}],
[{"id":1, time: "00:15" }],
[{"id":1, time: "00:20" }],
[{"id":4, time: "00:35" }]]
}
firebase.js
plugins
在组件中:
import firebase from 'firebase'
import 'firebase/firestore' //if use firestore
if (!firebase.apps.length) {
firebase.initializeApp({
apiKey: "xxx",
authDomain: "xxx,
databaseURL: "xxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId: "xxx"
})
}
firebase.firestore().settings({ timestampsInSnapshots: true })
const db = firebase.firestore()
const storage = firebase.storage() //if use storage
export { storage, db }