Web 应用程序中的 Firebase 存储:storage.useEmulator 不是函数
Firebase Storage in Web Application: storage.useEmulator is not a function
在我的本地 Web 应用程序开发环境中,Web 应用程序可以正确访问 Firestore 模拟器,但不能访问 Storage 模拟器。相反,它访问生产存储。
我从 http://localhost:5000/__/firebase/8.3.0/firebase-storage.js
加载模块
我已经从 https://firebase.google.com/docs/emulator-suite/connect_storage#web-v8:
尝试过这个
var storage = firebase.storage();
storage.useEmulator("localhost", 9199);
但是useEmulator函数不存在。怎么会这样?
您在打开之前是否配置了连接?
var firebaseConfig = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket-url>'
};
firebase.initializeApp(firebaseConfig);
而且,我没有直接的经验,但是你试过这种方法吗?
firebase.storage.useEmulator('localhost', xxxx)
请注意,这可能是一项正在进行的工作:试试这个命令:
firebase --open-sesame storageemulator
功能storage.useEmulator
是在更高版本的firebase中引入的。
在我的本地 Web 应用程序开发环境中,Web 应用程序可以正确访问 Firestore 模拟器,但不能访问 Storage 模拟器。相反,它访问生产存储。
我从 http://localhost:5000/__/firebase/8.3.0/firebase-storage.js
我已经从 https://firebase.google.com/docs/emulator-suite/connect_storage#web-v8:
尝试过这个var storage = firebase.storage();
storage.useEmulator("localhost", 9199);
但是useEmulator函数不存在。怎么会这样?
您在打开之前是否配置了连接?
var firebaseConfig = {
apiKey: '<your-api-key>',
authDomain: '<your-auth-domain>',
databaseURL: '<your-database-url>',
storageBucket: '<your-storage-bucket-url>'
};
firebase.initializeApp(firebaseConfig);
而且,我没有直接的经验,但是你试过这种方法吗?
firebase.storage.useEmulator('localhost', xxxx)
请注意,这可能是一项正在进行的工作:试试这个命令:
firebase --open-sesame storageemulator
功能storage.useEmulator
是在更高版本的firebase中引入的。