【问题标题】:Using React.js on Codepen.io, Why is the custom tag not rendering?在 Codepen.io 上使用 React.js,为什么自定义标签不渲染?
【发布时间】:2017-09-07 17:26:11
【问题描述】:

可能是一个非常初学者和愚蠢的问题,但仍然,每个人都首先学习..

HTML

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

CSS(SCSS)

$back:#1D1F20;
$font:'Open Sans',sans serif;
body{
  background-color:$back;
  padding:20px;
  h1{
    font-family:$font;
    color:white;
  }
  DisplayBox{
    font-family:$font;
    color:white;
  }
}

JS(巴别塔)

var DisplayBox=React.createClass({
  render:function(){
        return (
          <h1>Marked</h1>
        );
    }
});

React.render(<DisplayBox />,document.getElementById("container"));

我的目标是在#container 中呈现自定义标签 DisplayBox,但它没有在 codepen.io 中呈现 JS config in CodepenCSS config

提前感谢您的帮助:-)

【问题讨论】:

标签: javascript css reactjs babeljs codepen


【解决方案1】:

代替

React.render(<DisplayBox />,document.getElementById("container"));

使用

ReactDOM.render(<DisplayBox />,document.getElementById("container"));

检查工作的example

查看difference between React and ReactDOM

【讨论】:

    猜你喜欢
    • 2017-04-19
    • 1970-01-01
    • 2012-02-12
    • 2017-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多