React是Facebook開源的JavaScript庫,用于構建UI。你可以在React里傳遞多種類型的參數(shù),如聲明代碼,幫助你渲染出UI、也可以是靜態(tài)的HTML DOM元素、也可以傳遞動態(tài)變量、甚至是可交互的應用組件。(文字來自JS開發(fā)者微博)
特點:
示例
一個簡單的組件
下面這段代碼將會在在頁面容器中呈現(xiàn)出“Hello John”:
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return <
div
>{'Hello ' + this.props.name}div
>;
}});
React.renderComponent(<
HelloMessage
name
=
"John"
/>, mountNode);
該例使用一個類似XML語法的JSX來構建組件,實現(xiàn)一個render()方法,并且根據(jù)輸入的數(shù)據(jù)返回相應的結果。輸入的數(shù)據(jù)作為XML屬性傳遞給組件,render()方法通過this.props訪問這些輸入的數(shù)據(jù)。
更多示例與教程,大家可以訪問官網(wǎng)教程:http://facebook.github.io/react/docs/tutorial.html
官網(wǎng)主頁:http://facebook.github.io/react/index.html
下載地址: http://facebook.github.io/react/downloads.html
GitHub地址: https://github.com/facebook/react