简体   繁体   English

在浏览器中使用带有reactjs的引导程序

[英]using bootstrap with reactjs in browser

I am working on a Django project in python. 我正在用python开发Django项目。 I am trying to use bootstrap3.3 with ReactJS. 我试图将bootstrap3.3与ReactJS一起使用。 I do not use any package manager because I want to use ReactJS in browser for few pages so I made it simple. 我不使用任何包管理器,因为我想在浏览器中使用ReactJS来浏览几页,因此我简化了它。

I include javascript libraries in following order 我按以下顺序包含javascript库

<script src="/static/jquery/3.1.0/jquery.min.js"></script>
<script src="/static/react/15.3.0/react.min.js"></script>
<script src="/static/react-dom/15.3.0/react-dom.min.js"></script>
<script src="/static/babel-standalone/6.12.0/babel.min.js"></script>
<script src="/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/bootstrap/3.3.7/css/bootstrap.min.css">

Now, in my app/template/app folder I create login.html and write some html with bootstrap as follow: 现在,在我的app / template / app文件夹中,创建login.html并使用bootstrap编写一些html,如下所示:

<div class="container">
  <div class="row">
    <div class="col-md-4 col-md-offset-4">
      <div class="login-panel panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">Enter email below</h3>
        </div>
        <div class="panel-body">
          <form role="form">
            <fieldset>
              <div class="form-group">
                <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus />
              </div>
              <a href="index.html" class="btn btn-lg btn-success btn-block">Login</a>
            </fieldset>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

and I got pretty form on my page 我的页面上有漂亮的表格

在此处输入图片说明

Now I try to inject same html through ReactJS but whole CSS coloring vanished 现在我尝试通过ReactJS注入相同的html,但是整个CSS的颜色消失了

在此处输入图片说明

I do not have idea what i am doing wrong, can anybody help me ? 我不知道我在做什么错,有人可以帮助我吗?

Following is ReactJS code: 以下是ReactJS代码:

var ReactLoginForm = React.createClass({
  render: function() {
    return (
      <div class="row">
        <div class="col-md-4 col-md-offset-4">
          <div class="login-panel panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">Enter email below</h3>
            </div>
            <div class="panel-body">
              <form role="form">
                <fieldset>
                  <div class="form-group">
                    <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus />
                  </div>
                  <a href="index.html" class="btn btn-lg btn-success btn-block">Login</a>
                </fieldset>
              </form>
            </div>
          </div>
        </div>
      </div>
    );
  }
});

ReactDOM.render(
  <ReactLoginForm />,
  document.getElementById('loginFrm')
);

And html code: 和html代码:

<div class="container">
  <div id="loginFrm"></div>
</div>

Try using 'className' as the attribute instead of 'class' as 'class' is a reserved word in javascript and JSX is based on javascript. 尝试使用“ className”作为属性,而不是“ class”,因为“ class”是javascript中的保留字,而JSX基于javascript。 Same is the case with the 'for' attribute. “ for”属性也是如此。 You would have to use 'htmlFor' instead. 您将不得不使用'htmlFor'代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM