我正在尝试使用Firebase远程配置。对于这个设置https://firebase.google.com/docs/remote-config/use-config-web#add-remote-config-to-your-app,我遵循了firebase文档。但是我得到了这个错误,没有捕获TypeError: firebase.remoteConfig不是一个函数。
下面是我要做的:
index.html文件
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "api-key",
authDomain: "project-id.firebaseapp.com",
databaseURL: "https://project-id.firebaseio.com",
projectId: "project-id",
storageBucket: "project-id.appspot.com",
messagingSenderId: "sender-id",
appId: "app-id",
measurementId: "G-measurement-id",
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<script>
const remoteConfig = firebase.remoteConfig();
remoteConfig.settings = {
minimumFetchIntervalMillis: 3600000,
};
remoteConfig.defaultConfig = ({
'test': 'Welcome',
});
console.log(remoteConfig.getasString("test"));
</script
我想我在这行const remoteConfig = firebase.remoteConfig();中得到了这个错误。提前谢谢。
发布于 2020-03-17 20:05:30
在使用远程配置之前,您需要添加以下脚本:
<script src="https://www.gstatic.com/firebasejs/7.11.0/firebase-remote-config.js"></script>有关如何设置的更多信息,请查看此处:
发布于 2020-08-06 06:11:21
在我的React应用程序中,问题是缺少下面的import语句:
import "firebase/remote-config";
https://stackoverflow.com/questions/60722004
复制相似问题