質問編集履歴

4

firebase

2022/01/14 13:39

投稿

DKI
DKI

スコア11

test CHANGED
File without changes
test CHANGED
@@ -201,4 +201,50 @@
201
201
 
202
202
  は実行済み
203
203
 
204
-
204
+ https://firebase.google.com/docs/web/setup
205
+
206
+ こちらの記事を参考にして、main.jsを
207
+
208
+ ```javascript
209
+ import Vue from 'vue'
210
+ import App from './App.vue'
211
+
212
+
213
+
214
+ // Import the functions you need from the SDKs you need
215
+ import { initializeApp } from 'firebase/app';
216
+ import { getFirestore, collection, getDocs } from 'firebase/firestore/lite';
217
+ // Follow this pattern to import other Firebase services
218
+ // import { } from 'firebase/<service>';
219
+
220
+ // TODO: Add SDKs for Firebase products that you want to use
221
+ // https://firebase.google.com/docs/web/setup#available-libraries
222
+
223
+ // Your web app's Firebase configuration
224
+ const firebaseConfig = {
225
+
226
+ };
227
+
228
+ // Initialize Firebase
229
+ const app = initializeApp(firebaseConfig);
230
+ const db = getFirestore(app);
231
+ db
232
+ // Get a list of cities from your database
233
+ async function getCities(db) {
234
+ const citiesCol = collection(db, 'cities');
235
+ const citySnapshot = await getDocs(citiesCol);
236
+ const cityList = citySnapshot.docs.map(doc => doc.data());
237
+ return cityList;
238
+ }
239
+
240
+ export default {getCities};
241
+
242
+ Vue.config.productionTip = false
243
+
244
+ new Vue({
245
+ render: h => h(App),
246
+ }).$mount('#app')
247
+
248
+ ```
249
+ ともしてみましたが、うまく行きません。
250
+

3

ver9

2022/01/14 13:29

投稿

DKI
DKI

スコア11

test CHANGED
File without changes
test CHANGED
@@ -191,6 +191,14 @@
191
191
 
192
192
  ```
193
193
 
194
+ 試したこと
195
+
196
+ https://qiita.com/massu159/items/4a08effbff720dfc107c
197
+
198
+ こちらを参考にver9のimport方法に書き換える
199
+
194
200
  npm install --save firebase
195
201
 
196
202
  は実行済み
203
+
204
+

2

npm install --save firebase

2022/01/14 13:18

投稿

DKI
DKI

スコア11

test CHANGED
File without changes
test CHANGED
@@ -143,8 +143,9 @@
143
143
 
144
144
  ```javascript
145
145
  pakage.json
146
+
146
147
  {
147
- "name": "sample123",
148
+ "name": "firebase",
148
149
  "version": "0.1.0",
149
150
  "private": true,
150
151
  "scripts": {
@@ -187,4 +188,9 @@
187
188
  ]
188
189
  }
189
190
 
191
+
190
192
  ```
193
+
194
+ npm install --save firebase
195
+
196
+ は実行済み

1

pakage.json

2022/01/14 13:15

投稿

DKI
DKI

スコア11

test CHANGED
File without changes
test CHANGED
@@ -139,3 +139,52 @@
139
139
  }).$mount('#app')
140
140
 
141
141
  ```
142
+
143
+
144
+ ```javascript
145
+ pakage.json
146
+ {
147
+ "name": "sample123",
148
+ "version": "0.1.0",
149
+ "private": true,
150
+ "scripts": {
151
+ "serve": "vue-cli-service serve",
152
+ "build": "vue-cli-service build",
153
+ "lint": "vue-cli-service lint"
154
+ },
155
+ "dependencies": {
156
+ "core-js": "^3.6.5",
157
+ "firebase": "^9.6.2",
158
+ "vue": "^2.6.11"
159
+ },
160
+ "devDependencies": {
161
+ "@vue/cli-plugin-babel": "~4.5.0",
162
+ "@vue/cli-plugin-eslint": "~4.5.0",
163
+ "@vue/cli-service": "~4.5.0",
164
+ "babel-eslint": "^10.1.0",
165
+ "eslint": "^6.7.2",
166
+ "eslint-plugin-vue": "^6.2.2",
167
+ "vue-template-compiler": "^2.6.11"
168
+ },
169
+ "eslintConfig": {
170
+ "root": true,
171
+ "env": {
172
+ "node": true
173
+ },
174
+ "extends": [
175
+ "plugin:vue/essential",
176
+ "eslint:recommended"
177
+ ],
178
+ "parserOptions": {
179
+ "parser": "babel-eslint"
180
+ },
181
+ "rules": {}
182
+ },
183
+ "browserslist": [
184
+ "> 1%",
185
+ "last 2 versions",
186
+ "not dead"
187
+ ]
188
+ }
189
+
190
+ ```