我正在 Laravel 中创建一个简单的 crud 并在我遇到此错误时对 js 做出react
app.js:21988 Warning: Invalid DOM property `for`. Did you mean `htmlFor`?
in label (created by Add)
in div (created by Add)
in form (created by Add)
in div (created by Add)
in Add (created by Context.Consumer)
in Route (created by Index)
in div (created by Index)
in Router (created by BrowserRouter)
in BrowserRouter (created by Index)
in Index (created by Context.Consumer)
in Route (created by Header)
in div (created by Header)
in Router (created by BrowserRouter)
in BrowserRouter (created by Header)
in Header (created by Index)
in div (created by Index)
in div (created by Index)
in div (created by Index)
in div (created by Index)
in div (created by Index)
in Index
这是我的代码
import React, { Component } from 'react';
import axios from 'axios';
export default class Add extends Component {
constructor()
{
super();
this.onChangeBlogsName = this.onChangeBlogsName.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.state={
blogs_name:''
}
}
onChangeBlogsName(e){
this.setState({
blogs_name:e.target.value
});
}
onSubmit(e)
{
e.preventDefault();
const blogs = {
blogs_name : this.state.blogs_name
}
axios.post('http://127.0.0.1:8000/blogs/store' ,blogs)
.then(res=>console.log(res.data));
}
render() {
return (
<div>
<form onSubmit={this.onSubmit} >
<div className="form-group">
<label for="blogs_name">Title</label>
<input type="text" className="form-control" id="blogs_name"
value={this.state.blogs_name}
onChange={this.onChangeBlogsName} />
</div>
<button type="submit" className="btn btn-primary">Submit</button>
</form>
</div>
);
}
}