Ziv 小威
A Frontend Developer
分享人:左威威
GitHub: https://github.com/wewoor
Blog: http://imziv.com/
QQ: 191879617
Email: wewoor@foxmail.com
ReactJS是由Facebook和Instagram团队一同打造的一个用于构建用户界面的Javascript库。大部分人把ReactJS理解为MVC中View的部分。
单向数据绑定(one-way data binding)
<ul>
<%
String [] arr = {"foo", "bar", "baz"};
for (int i = 0 ; i < arr.length; i ++) {
%>
<li><%=arr[i]%></li>
<%
}
%>
</ul>
<ul>
<#list ["foo", "bar", "baz"] as x>
${x}
</#list>
</ul>
var arr = ["foo", "bar", "baz"];
var li = "";
for (var i = 0; i < arr.length; i++) {
li += '<li>' + arr[i] + '</li>';
}
$("#ULContent").html(li);
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
var myLi = React.createElement({
render: function() {
var arr = this.props.data.map(function(item) {
return <li>{item}</li>
});
return (
<ul>
{arr}
</ul>
}
}
});
ReactDOM.render(
<myLi data=["foo", "bar", "baz"]>,
document.getElementById('myUL')
);
By Ziv 小威