?? ?????? ??? ? ? ???? ?? ?????? ?? ??? ??(??? ?? ?? ??)
Sep 11, 2018 pm 04:45 PMReact? "?? ??"?? "???" ? ??? ?????? ???? ?? JavaScript ??????, ?? ?? Facebook? ? ??????? ? ??? ??? ? ?????. ?? ??? ???????
1. ??:
1. ?????. ?? ????? ??????? ?? ????? ??? ???? React? ???? ??? ? ???? UI ????? ?????.
2. ??? ???? ???? React? ????? F5? ???? ?? ?????. ???? ?? ??? ??? ???????. React? ??? ??? ?? ??? ??? ????. ??? React? ???? ?? ??? ??? ?? ?????. ???? ???? ?? ?? ?? ???, ??? ? ?? ??? ? ?????.
?? ?? ??? ???? ???.
React? MVC ?????? ????.
# ????#React? ???? ???? ????
??? ????? ?? ?????
2 . ?? ??#???? #?? ? ???????? DOM ??? ????? ?? ??????? DOM ????? ????? ??? ?? ???. DOM? ?? ??? ??? ??? ?? React? ???? DOM ?? ?? DOM? ?????? ???? ??? ??? ?????. React? ???? ??? ?? ?? DOM?
Virtual DOM???. DOM? ??? ????, ??? ????? ??? ?????. ?? DOM? ? Virtual DOM? ?? ??????, ? Virtual DOM? ?? DOM? ????? ?????. ? ?? ?? DOM ?? ??? ?? ??? ? ??? ? ?? ??? ?????? React?? diff ????? ?? ?????. Virtual DOM? ??????? ?? ?? DOM? ?? ??? ?? ???? ??? ????. React? ??? ??? ?? ??? ??? ? ? diff ????? ???? ?? ? ?? ???? ?? ?? ?? ?????. ?? DOM? ?????? ?????. DOM ??? ??? ????? Virtual DOM??? commonent?? ???. Virtual DOM? ??? ?? ??? ??? ??? ?? ?? ?????.
??: React??? ?? ??? ??? ?? ?????. ?? ??? ??? DOM ??? ? ????? ??? ? ?? ?????.
?? ? ???React? ?? DOM? ???? ??, ?? ??? ????? ??, ??? ?? ? ??? ???? ??? ??? ????. State? Render? ?? ??? ??? ?????. ?? ???? ????? ???? ? ??? ?? ???? ???? ????. ???? ???? ?? ????? ?? Render? ?????. ??? ???? ??? setState ???? ???? ????? ? ????. ?? ?? ???? ??? ???: # ????#
<!DOCTYPE html> <html> <head> <script src="http://fb.me/react-0.12.1.js"></script> <script src="http://fb.me/JSXTransformer-0.12.1.js"></script> </head> <body> <p id="example"></p> <script type="text/jsx"> React.render( <h1>Hello, world!</h1>, document.getElementById('example') ); </script> </body> </html>????? ???? Hello, world!?? ??? ??? ?? ? ? ????.
JSXTransformer.js? JSX ?? ??? ?????. JSX? Javascript? HTML ??? ??? ? ?? ?????. ??? ?? ??? React? ?? Javascript ???? ?????.
(??? ??? ??? PHP ??? ????React ?? ???
?? ?????.)? ?? ??:
<html> <head> <title>Hello React</title> <script src="http://fb.me/react-0.12.1.js"></script> <script src="http://fb.me/JSXTransformer-0.12.1.js"></script> <script src="http://code.jquery.com/jquery-1.10.0.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script> <style> #content{ width: 800px; margin: 0 auto; padding: 5px 10px; background-color:#eee; } .commentBox h1{ background-color: #bbb; } .commentList{ border: 1px solid yellow; padding:10px; } .commentList .comment{ border: 1px solid #bbb; padding-left: 10px; margin-bottom:10px; } .commentList .commentAuthor{ font-size: 20px; } .commentForm{ margin-top: 20px; border: 1px solid red; padding:10px; } .commentForm textarea{ width:100%; height:50px; margin:10px 0 10px 2px; } </style> </head> <body> <p id="content"></p> <script type="text/jsx"> var staticData = [ {author: "張飛", text: "我在寫一條評論~!"}, {author: "關(guān)羽", text: "2貨,都知道你在寫的是一條評論。。"}, {author: "劉備", text: "哎,咋跟這倆逗逼結(jié)拜了!"} ]; var converter = new Showdown.converter();//markdown /** 組件結(jié)構(gòu): <CommentBox> <CommentList> <Comment /> </CommentList> <CommentForm /> </CommentBox> */ //評論內(nèi)容組件 var Comment = React.createClass({ render: function (){ var rawMarkup = converter.makeHtml(this.props.children.toString()); return ( <p className="comment"> <h2 className="commentAuthor"> {this.props.author}: </h2> <span dangerouslySetInnerHTML={{__html: rawMarkup}} /> </p> ); } }); //評論列表組件 var CommentList = React.createClass({ render: function (){ var commentNodes = this.props.data.map(function (comment){ return ( <Comment author={comment.author}> {comment.text} </Comment> ); }); return ( <p className="commentList"> {commentNodes} </p> ); } }); //評論表單組件 var CommentForm = React.createClass({ handleSubmit: function (e){ e.preventDefault(); var author = this.refs.author.getDOMNode().value.trim(); var text = this.refs.text.getDOMNode().value.trim(); if(!author || !text){ return; } this.props.onCommentSubmit({author: author, text: text}); this.refs.author.getDOMNode().value = ''; this.refs.text.getDOMNode().value = ''; return; }, render: function (){ return ( <form className="commentForm" onSubmit={this.handleSubmit}> <input type="text" placeholder="Your name" ref="author" /><br/> <textarea type="text" placeholder="Say something..." ref="text" ></textarea><br/> <input type="submit" value="Post" /> </form> ); } }); //評論塊組件 var CommentBox = React.createClass({ loadCommentsFromServer: function (){ this.setState({data: staticData}); /*# ????# ??? ???? ??? ???? ????.
$.ajax({ url: this.props.url + "?_t=" + new Date().valueOf(), dataType: 'json', success: function (data){ this.setState({data: data}); }.bind(this), error: function (xhr, status, err){ console.error(this.props.url, status, err.toString()); }.bind(this) }); */ }, handleCommentSubmit: function (comment){ //TODO: submit to the server and refresh the list var comments = this.state.data; var newComments = comments.concat([comment]); //這里也不向后端提交了 staticData = newComments; this.setState({data: newComments}); }, //初始化 相當(dāng)于構(gòu)造函數(shù) getInitialState: function (){ return {data: []}; }, //組件添加的時(shí)候運(yùn)行 componentDidMount: function (){ this.loadCommentsFromServer(); this.interval = setInterval(this.loadCommentsFromServer, this.props.pollInterval); }, //組件刪除的時(shí)候運(yùn)行 componentWillUnmount: function() { clearInterval(this.interval); }, //調(diào)用setState或者父級組件重新渲染不同的props時(shí)才會重新調(diào)用 render: function (){ return ( <p className="commentBox"> <h1>Comments</h1> <CommentList data={this.state.data}/> <CommentForm onCommentSubmit={this.handleCommentSubmit} /> </p> ); } }); //當(dāng)前目錄需要有comments.json文件 //這里定義屬性,如url、pollInterval,包含在props屬性中 React.render( <CommentBox url="comments.json" pollInterval="2000" />, document.getElementById("content") ); </script> </body> </html>
??:
# ????#? ?? ???????. (??? ??? ??? PHP ??? ???? React ??? ??? ?? ?????.) ?? ???.
? ??? ?? ?????? ??? ? ? ???? ?? ?????? ?? ??? ??(??? ?? ?? ??)? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

NetflixusesAcustomFrameworkCalled "Gibbon"BuiltonReact, NotreactorVuedirectly.1) TeamExperience : 2) ProjectComplexity : vueforsimplerProjects, 3) CustomizationNeeds : reactoffersmoreflex.4)

React Ecosystem?? ??? ?? ????? (? : Redux), ??? ????? (? : Reactrouter), UI ?? ?? ????? (? : ?? -UI), ??? ?? (? : Jest) ? Webpack? ?? ?? ?? (? : Webpack)? ?????. ??? ??? ???? ??????? ????? ???? ???? ?? ?? ? ?? ???? ???? ? ??? ?? ?????.

Netflix? React? ??? ?? ??? ??? ?????. 1) React? ?? ??? ? ?? ??? ??? ???? Netflix? ??? ?? ?????. 2) ?? ???? ?? Netflix? ??? ?????? ??? ????, ?? ?? ? ??? ??? ?? ?? ??? ??? ?????. 3) React? ?? DOM ? ?? ?? ????? ??? ??? ? ??? ?? ?? ??? ??????.

React? Meta? ??? ?????? ???? ?? ?? ? JavaScript ??????? ??? ?? ?? ?? ? ?? DOM ?????. 1. ?? ?? ? ?? ?? : React? ?? ?? (?? ?? ???) ? ?? (? : usestate)? ?? ??? ???? ?? ??? ? ?? ??? ?????. 2. ?? DOM ? ?? ??? : ?? DOM? ?? ?? DOM? ????? ?????? ??? ??????. 3. ???? ? ?? : ?? (? : ???) ?? ?? ??? ????? ???? ??? ??? ?? ? ? ??????. 4. ?? ? : ?? Helloworld ?? ???? ?? ??? ? ?? (Usecontext ?

React? ??? ??? ? ?? ?? ??, ?? ??? ? ?? ?? ???? ?? ??? ??? ? ????. 1) RECT? ?? ??? ?? ? ??? ?? ????? ??? ? ?? ?? ??? ?????. 2) ?? ???? ?? ??? ?? ?????? ??????. 3) React? ?? ??? ????? ?? GraphQL ? TypeScript? ?? ??? ?? ?? ? ????.

React? ??? ???? ?????, ?? ??? ?? ?????. 1) ?? ?? ?? ??? ?? ??? ?? ??????. 2) ?? DOM ??? ?? ??? ??? ????? ?? ? ? ??? ??????. 3) ??? ???? ?? ?? ?????? ??? ?????. React? ??? ???? ????? ?????? ?? ??? ?? ??? ????? ????? ?? ?? ??? ??? ?????? ?? ? ? ????.

React? ??? ?????? ?????? ??? ?? ??? ?????. ??? ??? ??? ?? ? ?? ????? ???? ? ?????. React? ?? ? ???? UI ????? ???? ??? ??? ??? ??? ??? ??? ???? ?????. ?? ??, ???? ?? ??, ? ?? ? ?? ?? ??? ?? ???????.

React? ?? ??? ?? ????? ??? ??? ?????? ?????? JavaScript ????????. 1. React? ??? ?? ??? ? ?? DOM?? UI ??? ??? ??????. 2. VUE? ??? ? React? ? ????? ??? ?? ????? ??? ????? ?????. 3. Angular? ???? React? ? ??? ?? ?? ??? ???? ???? ??? ????? ?????.
