2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

WebAPIs と Firebase と Vue.js 開発関係の有益な資料へのリンク

Last updated at Posted at 2021-12-18

WebAPI

Firebase

firebase emulators の storage も使えるようになりました。下記のコードでいけます (firebase v8の場合)

.js
import firebase from 'firebase/app'; 
require("firebase/functions");
require("firebase/firestore");
require("firebase/storage");

// 以下に apiKey のコードを貼る
const firebaseConfig = {
  apiKey: "xxxxxx",
  authDomain: "yourproject.firebaseapp.com",
  projectId: "yourproject",
  storageBucket: "yourproject.appspot.com",
  messagingSenderId: "xxxxxxxxxxxx",
  appId: "1:yyyyyyyyy:web:xxxxxxxxxxx"
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

const isEmulating = window.location.hostname === "localhost";
if (isEmulating) {
  firebase.auth().useEmulator("http://localhost:9099");
  firebase.functions().useEmulator("localhost", 5001);
  firebase.firestore().useEmulator("localhost", 8080);
  firebase.storage().useEmulator('localhost', 9199);
}

storage エミュレータは windows で動かすと、400kb より大きいファイルを置こうとすると、落ちることがあるようです。どうしても落ちる場合は、storage と auth だけ emulator から外します。

vue2 / firebase v8

yarn install 時のバージョンは下記に揃えておけば、従来通りいけるようです。

.sh
$ npm -v
8.1.3
$ node -v
v14.18.1
(firebase ではv16 にしろと言われるかも)
$ yarn -v
1.22.11
$ firebase --version
10.2.1
$vue --version
@vue/cli 4.5.13
$ vue create myapp
(vue2)
$ cd myapp
$ vue add vuetify
(default)
$ yarn add firebase@^8.10.0
$ yarn add firebaseui@^5.0.0
$ yarn add vue-router@^3.2.0
$ yarn add @mdi/font
$ yarn dev
(動作テスト)
$ firebase init
$ yarn build
$ firebase init emulators
$ firebase emulators:start

gitbun からレポジトリを clone した場合

.sh
$ yarn install
$ firebase use myproject
# 必要に応じて
$ cd functions
$ npm i
$ cd ..
$ yarn build
$ firebase emulators:start

Vue 参考資料

Vuetify

Vuetify でエラーがでないままレンダリングされない場合は、v-bind,.v-on, v-model, v-slot あたりに設定されている変数やメソッド名が、script 以下に定義されていないことが多い。

M5Stack

Javascript 関連

公開資料

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?