我在向我正在处理的应用添加身份验证时遇到问题。 在没有auth的情况下,一切都能正常使用firebase,直到我开始添加这些新行,基本上只是:
You are given a memory system with 2MB of virtual memory, 8KB page size,
512 MB of physical memory, TLB contains 16 entries, 2-way set associative.
How many bits are needed to represent the virtual address space?
我有一个配置文件(config.js),它只包含DB_CONFIG的导出(包含我所有正确的信息)。这就是我遇到问题的地方。我之后的教程在配置文件中导入并初始化了firebase,而我在App.js文件中这样做了。我已经尝试了几个小时不同的事情,没有什么对我有用。如果我将firebase导入我的配置并在那里初始化应用程序,它会破坏我的App.js.这是my code vs. what I'm trying to follow.
的要点是否有一种简单的方法可以将auth和提供程序设置并导入我的App.js文件而不会改变太多?
答案 0 :(得分:1)
在查看您的代码后,我对其进行了一些更改,也许这种方法有帮助吗?
import * as firebase from 'firebase'
import { DB_CONFIG } from './Config/config';
// Configure firebase and it will be available globally.
firebase.initializeApp(DB_CONFIG)
// Once initialized you just need to create the provider and auth
const provider = new firebase.auth.GoogleAuthProvider();
const auth = firebase.auth();
class App extends Component {
constructor(props){
super(props);
// And just call firebase.database() to access database functionality.
// You don't even need to assign it to a local variable as you can access
// it anywhere in your code just by importing firebase
// and calling firebase.database() and also firebase.auth()
this.databaseRef = firebase.database().ref().child('players');
}
}
PS:我会删除你的要点,因为即使你更改了配置文件,你的配置信息仍然可以在要点修订版中找到......