我正在尝试使用reactJS文件中的按钮。这是我的代码
export class Add extends React.Component {
render() {
return (
<div>
<Button bsStyle="primary" bsSize="large">
Add
</Button>
</div>
);
}
}
但反应正在给我:
'Button' is not defined react/jsx-no-undef
我在package.json中的依赖项中包含了bootstrap,以及popper.js和jquery,我尝试过npm install bootstrap。我也确定了
import 'bootstrap/dist/css/boostrap.min.css';
import 'bootstrap/dist/js/bootstrap.min.js';
在我的主要Js文件中。
我也尝试过没有运气。
AMR,
看起来你正在尝试使用组件,所以我相信你正在尝试使用React-Bootstrap。在这里:https://react-bootstrap.github.io/getting-started/introduction
运行以下命令首先安装它:
npm install --save react-bootstrap
然后将其包含在您的文件中:
import Button from 'react-bootstrap/lib/Button';
编辑:按照评论中的建议添加样式:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
是的你可以。但我建议你检查这个库。 ReactStrap