一旦我解雇了evt.preventDefault(),我怎么能再次恢复默认操作?
我正在阅读关于按钮标签的Bootstrap文档(http://getbootstrap.com/css/#buttons-tags),因为<button>和<a>标签具有完全相同的外观,我发现了这个:
跨浏览器渲染
作为最佳实践,我们强烈建议
<button>尽可能使用该元素以确保匹配跨浏览器呈现.
是什么原因导致我使用<button>标签(没有href属性)而不是<a>导航?
<button>在设计Web应用程序与页面本身交互时,当然还有提交表单时,可能会更好,但这一切都是什么?
[这个问题与SEO有关:<button> vs <a> HTML标签,但问题不一样]
我想FlashMessage在所需时间重新加载页面时显示错误(或成功)消息
我正在使用FlashMessage,我的代码看起来像
render() {
return (
{this.state.error ? <FlashMessage duration={5000}><strong>{this.state.error.message}</strong></FlashMessage> : ''}
//Some table here presenting data
<Button variant="outline-info" type="submit" size="lg" block className="button-custom" onClick={this.handleSubmit.bind(this)}>
Submit
</Button>
)}
Run Code Online (Sandbox Code Playgroud)
对于我的有状态组件,error由
handleSubmit(event) {
let data = {
name: this.state.name,
unit_price: this.state.unit_price,
length: this.state.length,
time: this.state.selectedDate,
instructor: this.state.instructor,
}
ApiService.postLesson(data)
.then(res => {
this.setState({
message: 'Success!'
});
})
.catch(error => {
this.setState({
message: error,
error: error,
});
console.log(error);
})
Run Code Online (Sandbox Code Playgroud)
};
而我的ApiService.postLesson是
const instance = axios.create({
headers: …Run Code Online (Sandbox Code Playgroud)