【发布时间】:2018-05-24 10:17:18
【问题描述】:
我是 React.js 的新手,自从我开始阅读文档和教程后,我不确定 Bootstrap 如何与 React.js 一起工作。
我看到了几个 npm 包,例如 reactstrap 或 react-bootstrap,但是,我不明白。 HTML 代码来自一个返回一段 HTML 的方法(像这样):
class App extends React.Component {
constructor(props) {
super(props);
this.state = {value: ''};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
this.setState({value: event.target.value});
}
handleSubmit(event) {
alert('A name was submitted: ' + this.state.value);
event.preventDefault();
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<label>
Name:
<input type="text" value={this.state.value} onChange={this.handleChange} />
</label>
<input type="submit" value="Submit" />
</form>
);
}
}
如果我是对的......
所以,我的问题是:
- 我应该将 Bootstrap 的
<link/>或<script/>添加到 index.html 中,添加到正文中还是标题中?
或
- 我是否必须从我的
App.js文件中包含 Bootstrap 并从方法中使用它?
PS:我已经开发多年了,但我从来没有做过任何 Javascript/HTML/CSS 网页,所以如果你有任何建议,提前谢谢!
我需要使用 Bootstrap 网格的逻辑来实现 HCI
感谢您的帮助
【问题讨论】:
-
您只需要在反应中添加 Bootstrap 对吗?如果是这样你需要在
index.html中添加css cdn@ -
但是如果我从我的index.html添加,如何从js端使用呢?
标签: html reactjs bootstrap-4