javascript - ReactJS CSS 类不工作

标签 javascript html css reactjs

我对使用 ReactJS 还是个新手。我想为特定表单创建一个类,但它不起作用

这是我的代码

import React, { Component, PropTypes } from 'react';
import s from './style.scss';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import { Grid, Row, Col } from 'react-bem-grid';
class OrderDetails extends Component {
  render() {
      return (
          <div>
            <Row>
              <form class="orderform">
                <h3>Product Details: </h3>
                  <Row>
                    <Col xs={5}>
                      Product: <br />
                      Category: <br />
                      Sub Category: <br />
                      Price: <br />
                      Color: <br />
                      Breakdown: 
                    </Col>
                    <Col xs={4}>
                      test
                    </Col>
                  </Row>
                <h3>Print Details</h3>
                  <Row>
                    <Col xs={5}>
                      Print Method: <br />
                      Position:   <br />
                      Length:   <br />
                      Width:  <br />
                      Colors
                    </Col>
                  </Row>
              </form>
            </Row>
          </div>
     );
  }
}
export default withStyles(OrderDetails, s);

这是我的 style.css 文件的代码

.orderform{
    color: red;
}

用一个简单的代码,我不确定为什么它不起作用。请指导我如何在 ReactJS 中使用类 CSS

最佳答案

替换为

return (
      <div>
        <Row>
          <form className="orderform">

由于 JSX 使用 className 而不是 class,来自 DOCS

Since JSX is JavaScript, identifiers such as class and for are discouraged as XML attribute names. Instead, React DOM components expect DOM property names like className and htmlFor, respectively.

关于javascript - ReactJS CSS 类不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35567803/

相关文章:

javascript - 剑道格动态编辑

Javascript 迭代器不起作用

android - 混合移动应用程序开发的最佳学习资源

javascript - 需要元素在页面刷新时识别它在页面上的位置

html - 永久删除 HTML5 Appcache list

javascript - 制作相同高度的子菜单和子子菜单

html - 具有明显问题的 CSS float 布局

jquery - Twitter Bootstrap 3 相同高度的流体网格布局?

javascript - 单击后从按钮上移除焦点

javascript - 将类添加到数组中的元素