问题描述
我想将 React-bootstrap 与我当前的 Rails 项目集成.我是 ReactJS 的新手,所以我认为使用 react-bootstrap 库会让事情变得更容易一些.但是,我发现配置非常困难.据说有一个 gem,但是一旦按照 README 上的说明进行操作,它就会抛出权限被拒绝"的错误.我尝试了从 react-bootstrap 网站截取的一段代码,它在没有 react-bootstrap 语法的情况下工作.但是,我尝试使用 Bower、npm、rails-assets gem 等的所有解决方案都不会渲染 react-bootstrap 语法.这是我的 Button.js.jsx 文件,它不会呈现到我的主页:
I would like to integrate React-bootstrap with my current Rails project. I am new to ReactJS, so I thought using the react-bootstrap lib would make things a bit easier. However, I find the configuration very hard. There is supposedly a gem for this, but it throws an error of 'Permission denied' once the instructions on the README are followed. I tried a snipped from the react-bootstrap web site, which works without the react-bootstrap syntax. However, all the solutions I have tried involing Bower, npm, rails-assets gem, etc., don't make the react-bootstrap syntax render. This is my Button.js.jsx file which won't render to my home page:
var button = ReactBootstrap.Button({
bsStyle: "success",
bsSize: "large",
children: "Register"
});
React.render(button, document.getElementById("content"));
非常欢迎提示和建议!
推荐答案
我今天遇到了类似的问题,将 react-bootstrap 包集成到我的 RoR 应用程序中,所以我找到了这个 gem:https://github.com/mariopeixoto/react-bootstrap-rails 基本上只需访问即可将所有反应引导组件供您使用一个全局变量 ReactBootstrap.
I had a similar issue today of integrating the react-bootstrap package into my RoR application, so I found this gem: https://github.com/mariopeixoto/react-bootstrap-rails which basically puts all react bootstrap components at your disposal by just accessing a global variable ReactBootstrap.
希望这会有所帮助!
这篇关于使用 Rails 4.2 配置 react-bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!