0

当您观看这个简单的 JSX 示例时:

var CommentBox = React.createClass({
  render: function() {
    return (
      <div className="commentBox">
        Hello, world! I am a CommentBox.
      </div>
    );
  }
});
React.render(
  <CommentBox />,
  document.getElementById('content')
);

如何更改“DOM 部分”:

  <div className="commentBox">
    Hello, world! I am a CommentBox.
  </div>

...动态基于我提交的变量?

4

1 回答 1

0

我希望我能正确理解你的问题。您使用大括号:

<div className="commentBox">
    {myVariable}
</div>

你不能在那里使用任意的 Javascript,只有表达式是有效的。

你可以在这里阅读:http: //facebook.github.io/react/docs/jsx-in-depth.html#javascript-expressions

于 2014-11-01T18:25:49.430 回答