您的位置:首页 > Web前端 > React

[React] React Fundamentals: JSX Deep Dive

2015-08-26 19:25 597 查看
"JSX transforms from an XML-like syntax into native JavaScript. XML elements and attributes are transformed into function calls and objects, respectively."

Input:

React.createClass({
render: function(){
var style = {
backgroundColor: '#ccc',
color: blue
};
return (
<div >
<a href="#"  style={style}/> {/*This is comment*/} Thisis message
{/*JSX don't have if else*/}
{i > 1 ? 'More than one' : 'one'}
{i>1&& 'More than one' }
</div>
)
}
})


output:

React.createClass({
render: function(){
var style = {
backgroundColor: '#ccc',
color: blue
};
return (
React.createElement("div", null,
React.createElement("a", {href: "#", style: style}), " ", /*This is comment*/" Thisis message",
/*JSX don't have if else*/
i > 1 ? 'More than one' : 'one',
i>1&& 'More than one'
)
)
}
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: