我的 JSX 文件中有以下简单的react代码:
/** @jsx React.DOM */
var Hello = React.createClass({
render: function() {
return <div><img src='http://placehold.it/400x20&text=slide1' alt={event.title} class="img-responsive"/><span>Hello {this.props.name}</span></div>;
}
});
React.renderComponent(<Hello name="World" />, document.body);
DOM中的输出如下:
<div data-reactid=".0">
<img src="http://placehold.it/400x20undefined1" data-reactid=".0.0">
<span data-reactid=".0.1">
<span data-reactid=".0.1.0">Hello </span>
<span data-reactid=".0.1.1">World</span>
</span>
</div>
我有两个问题:
- 图像 URL 呈现不正确,呈现为“ http://placehold.it/400x20undefined1 ”
- 我图片上的class消失了
有任何想法吗?