我在firebase中推送数据,但我想在我的数据库中存储唯一的id.有人可以告诉我,如何推送具有唯一ID的数据.
我是这样想的
writeUserData() {
var key= ref.push().key();
var newData={
id: key,
websiteName: this.webname.value,
username: this.username.value,
password : this.password.value,
websiteLink : this.weblink.value
}
firebase.database().ref().push(newData);
}
Run Code Online (Sandbox Code Playgroud)
错误是"ReferenceError:ref未定义"
我第一次使用react-route.当我尝试这个时,它给了我这个警告并且它没有工作"警告:链接是一个void元素标记,不能有children或使用props.dangerouslySetInnerHTML.检查Loginpanel的render方法."
我的代码是这样的.
render() {
return (
<div >
<input type="email" />
<input type="password"/><br/>
<link to="Index"> BLOCK
</link>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
而我的主要main.js是这样的
render(
<Router history={hashHistory}>
<Route path="/" component={Loginpanel} >
<Route path="Index" component={App}/>
<Route path="Form" component={Form} />
</Route>
</Router>,
document.getElementById('js-main'));
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我是新手做出反应并尝试使用内联样式获取背景图像.但它不起作用.
显示错误"url未定义"
render() {
return (
<div className="phase1"
style ={ { backgroundImage: url('https://lh3.googleusercontent.com/MOf9Kxxkj7GvyZlTZOnUzuYv0JAweEhlxJX6gslQvbvlhLK5_bSTK6duxY2xfbBsj43H=w300') } }>
<input id="search"
type="text"
placeholder={this.state.search}
onChange={this.updateSearch.bind(this)}/>
<Link className="button1" to="Form"> + </Link>
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)