Vue上的Firebase远程配置
我刚刚尝试在Vue上集成firebase自定义配置。我是新手,犯了这样的错误 我已经将firebase sdk添加到我的项目中。 这是我的main.jsVue上的Firebase远程配置,firebase,vue.js,firebase-remote-config,Firebase,Vue.js,Firebase Remote Config,我刚刚尝试在Vue上集成firebase自定义配置。我是新手,犯了这样的错误 我已经将firebase sdk添加到我的项目中。 这是我的main.js Vue.config.productionTip = false const config = { apiKey: "######################", authDomain: "######################", databaseURL: "
Vue.config.productionTip = false
const config = {
apiKey: "######################",
authDomain: "######################",
databaseURL: "######################",
projectId: "######################",
storageBucket: "######################",
messagingSenderId: "######################",
appId: "######################",
measurementId: "######################"
};
firebase.initializeApp(config);
new Vue({
router,
vuetify,
render: h => h(App)
}).$mount('#app')
我想在我的视图上使用firebase远程配置
<script>
import firebase from "firebase";
remoteConfig = firebase.remoteConfig();
// [START enable_dev_mode]
remoteConfig.settings = {
minimumFetchIntervalMillis: 3600000,
};
// [END enable_dev_mode]
// [START set_default_values]
remoteConfig.defaultConfig = ({
'is_auto_location': 'false',
});
// [END set_default_values]
remoteConfig.ensureInitialized()
.then(() => {
console.log('Firebase Remote Config is initialized');
setLocation();
})
.catch((err) => {
console.error('Firebase Remote Config failed to initialize', err);
});
function setLocation() {
this.isAutoLocation = remoteConfig.getString('is_auto_location');
}
</script>
从“firebase”导入firebase;
remoteConfig=firebase.remoteConfig();
//[启动启用\开发\模式]
remoteConfig.settings={
最小间隔毫秒:3600000,
};
//[结束启用\开发\模式]
//[开始设置默认值]
remoteConfig.defaultConfig=({
'is_auto_location':'false',
});
//[结束设置\u默认值]
remoteConfig.ensureInitialized()
.然后(()=>{
log('Firebase远程配置已初始化');
setLocation();
})
.catch((错误)=>{
console.error('Firebase远程配置未能初始化',err);
});
函数setLocation(){
this.isAutoLocation=remoteConfig.getString('is_auto_location');
}
请帮忙。
谢谢在main.js文件中导入firebase
import*作为firebase从“firebase”导入
firebase调用有一个很棒的vuejs包。您可以使用它在main.js文件中导入firebase(从“firebase”导入*作为firebase)@otniel请更新您的问题,因为它不在那里