我有以下簡單的反應代碼在我的JSX文件:陣營img標籤問題與URL和
/** @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'
- 我的圖像上的課程消失了
任何想法?
如果你檢查輸出,可以實現的alt屬性也不翼而飛。 :( – ruff 2015-10-20 08:45:52
該alt應該像'alt = {「boohoo」}'。 – 2016-11-10 15:54:10