{"id":692,"date":"2017-03-04T08:02:24","date_gmt":"2017-03-04T00:02:24","guid":{"rendered":"http:\/\/www.qdabc.cn\/?p=692"},"modified":"2017-03-04T08:03:53","modified_gmt":"2017-03-04T00:03:53","slug":"reactjs-%e5%85%a5%e9%97%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"http:\/\/www.qdabc.cn\/?p=692","title":{"rendered":"ReactJs \u5165\u95e8\u6559\u7a0b"},"content":{"rendered":"<p>\u73b0\u5728\u6700\u70ed\u95e8\u7684\u524d\u7aef\u6846\u67b6\u6709AngularJS\u3001React\u3001Bootstrap\u7b49\u3002\u81ea\u4ece\u63a5\u89e6\u4e86ReactJS\uff0cReactJs\u7684\u865a\u62dfDOM\uff08Virtual DOM\uff09\u548c\u7ec4\u4ef6\u5316\u7684\u5f00\u53d1\u6df1\u6df1\u7684\u5438\u5f15\u4e86\u6211\uff0c\u4e0b\u9762\u6765\u8ddf\u6211\u4e00\u8d77\u9886\u7565ReactJs\u7684\u98ce\u91c7\u5427~~ \u6587\u7ae0\u6709\u70b9\u957f\uff0c\u8010\u5fc3\u8bfb\u5b8c\uff0c\u4f60\u4f1a\u6709\u5f88\u5927\u6536\u83b7\u54e6~<\/p>\n<p>\u4e00\u3001ReactJS\u7b80\u4ecb<\/p>\n<p>React \u8d77\u6e90\u4e8e Facebook \u7684\u5185\u90e8\u9879\u76ee\uff0c\u56e0\u4e3a\u8be5\u516c\u53f8\u5bf9\u5e02\u573a\u4e0a\u6240\u6709 JavaScript MVC \u6846\u67b6\uff0c\u90fd\u4e0d\u6ee1\u610f\uff0c\u5c31\u51b3\u5b9a\u81ea\u5df1\u5199\u4e00\u5957\uff0c\u7528\u6765\u67b6\u8bbe Instagram \u7684\u7f51\u7ad9\u3002\u505a\u51fa\u6765\u4ee5\u540e\uff0c\u53d1\u73b0\u8fd9\u5957\u4e1c\u897f\u5f88\u597d\u7528\uff0c\u5c31\u57282013\u5e745\u6708\u5f00\u6e90\u4e86\u3002\u7531\u4e8e React \u7684\u8bbe\u8ba1\u601d\u60f3\u6781\u5176\u72ec\u7279\uff0c\u5c5e\u4e8e\u9769\u547d\u6027\u521b\u65b0\uff0c\u6027\u80fd\u51fa\u4f17\uff0c\u4ee3\u7801\u903b\u8f91\u5374\u975e\u5e38\u7b80\u5355\u3002\u6240\u4ee5\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u4eba\u5f00\u59cb\u5173\u6ce8\u548c\u4f7f\u7528\uff0c\u8ba4\u4e3a\u5b83\u53ef\u80fd\u662f\u5c06\u6765 Web \u5f00\u53d1\u7684\u4e3b\u6d41\u5de5\u5177\u3002<\/p>\n<p>ReactJS\u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/facebook.github.io\/react\/<\/p>\n<p>Github\u5730\u5740\uff1ahttps:\/\/github.com\/facebook\/react<\/p>\n<p>\u4e8c\u3001\u5bf9ReactJS\u7684\u8ba4\u8bc6\u53caReactJS\u7684\u4f18\u70b9<\/p>\n<p>\u9996\u5148\uff0c\u5bf9\u4e8eReact\uff0c\u6709\u4e00\u4e9b\u8ba4\u8bc6\u8bef\u533a\uff0c\u8fd9\u91cc\u5148\u603b\u7ed3\u4e00\u4e0b\uff1a<\/p>\n<p>React\u4e0d\u662f\u4e00\u4e2a\u5b8c\u6574\u7684MVC\u6846\u67b6\uff0c\u6700\u591a\u53ef\u4ee5\u8ba4\u4e3a\u662fMVC\u4e2d\u7684V\uff08View\uff09\uff0c\u751a\u81f3React\u5e76\u4e0d\u975e\u5e38\u8ba4\u53efMVC\u5f00\u53d1\u6a21\u5f0f\uff1b<\/p>\n<p>React\u7684\u670d\u52a1\u5668\u7aefRender\u80fd\u529b\u53ea\u80fd\u7b97\u662f\u4e00\u4e2a\u9526\u4e0a\u6dfb\u82b1\u7684\u529f\u80fd\uff0c\u5e76\u4e0d\u662f\u5176\u6838\u5fc3\u51fa\u53d1\u70b9\uff0c\u4e8b\u5b9e\u4e0aReact\u5b98\u65b9\u7ad9\u70b9\u51e0\u4e4e\u6ca1\u6709\u63d0\u53ca\u5176\u5728\u670d\u52a1\u5668\u7aef\u7684\u5e94\u7528\uff1b<\/p>\n<p>\u6709\u4eba\u62ffReact\u548cWeb Component\u76f8\u63d0\u5e76\u8bba\uff0c\u4f46\u4e24\u8005\u5e76\u4e0d\u662f\u5b8c\u5168\u7684\u7ade\u4e89\u5173\u7cfb\uff0c\u4f60\u5b8c\u5168\u53ef\u4ee5\u7528React\u53bb\u5f00\u53d1\u4e00\u4e2a\u771f\u6b63\u7684Web Component\uff1b<\/p>\n<p>React\u4e0d\u662f\u4e00\u4e2a\u65b0\u7684\u6a21\u677f\u8bed\u8a00\uff0cJSX\u53ea\u662f\u4e00\u4e2a\u8868\u8c61\uff0c\u6ca1\u6709JSX\u7684React\u4e5f\u80fd\u5de5\u4f5c\u3002<\/p>\n<p>1\u3001ReactJS\u7684\u80cc\u666f\u548c\u539f\u7406<\/p>\n<p>\u5728Web\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u603b\u9700\u8981\u5c06\u53d8\u5316\u7684\u6570\u636e\u5b9e\u65f6\u53cd\u5e94\u5230UI\u4e0a\uff0c\u8fd9\u65f6\u5c31\u9700\u8981\u5bf9DOM\u8fdb\u884c\u64cd\u4f5c\u3002\u800c\u590d\u6742\u6216\u9891\u7e41\u7684DOM\u64cd\u4f5c\u901a\u5e38\u662f\u6027\u80fd\u74f6\u9888\u4ea7\u751f\u7684\u539f\u56e0\uff08\u5982\u4f55\u8fdb\u884c\u9ad8\u6027\u80fd\u7684\u590d\u6742DOM\u64cd\u4f5c\u901a\u5e38\u662f\u8861\u91cf\u4e00\u4e2a\u524d\u7aef\u5f00\u53d1\u4eba\u5458\u6280\u80fd\u7684\u91cd\u8981\u6307\u6807\uff09\u3002React\u4e3a\u6b64\u5f15\u5165\u4e86\u865a\u62dfDOM\uff08Virtual DOM\uff09\u7684\u673a\u5236\uff1a\u5728\u6d4f\u89c8\u5668\u7aef\u7528Javascript\u5b9e\u73b0\u4e86\u4e00\u5957DOM API\u3002\u57fa\u4e8eReact\u8fdb\u884c\u5f00\u53d1\u65f6\u6240\u6709\u7684DOM\u6784\u9020\u90fd\u662f\u901a\u8fc7\u865a\u62dfDOM\u8fdb\u884c\uff0c\u6bcf\u5f53\u6570\u636e\u53d8\u5316\u65f6\uff0cReact\u90fd\u4f1a\u91cd\u65b0\u6784\u5efa\u6574\u4e2aDOM\u6811\uff0c\u7136\u540eReact\u5c06\u5f53\u524d\u6574\u4e2aDOM\u6811\u548c\u4e0a\u4e00\u6b21\u7684DOM\u6811\u8fdb\u884c\u5bf9\u6bd4\uff0c\u5f97\u5230DOM\u7ed3\u6784\u7684\u533a\u522b\uff0c\u7136\u540e\u4ec5\u4ec5\u5c06\u9700\u8981\u53d8\u5316\u7684\u90e8\u5206\u8fdb\u884c\u5b9e\u9645\u7684\u6d4f\u89c8\u5668DOM\u66f4\u65b0\u3002\u800c\u4e14React\u80fd\u591f\u6279\u5904\u7406\u865a\u62dfDOM\u7684\u5237\u65b0\uff0c\u5728\u4e00\u4e2a\u4e8b\u4ef6\u5faa\u73af\uff08Event Loop\uff09\u5185\u7684\u4e24\u6b21\u6570\u636e\u53d8\u5316\u4f1a\u88ab\u5408\u5e76\uff0c\u4f8b\u5982\u4f60\u8fde\u7eed\u7684\u5148\u5c06\u8282\u70b9\u5185\u5bb9\u4eceA\u53d8\u6210B\uff0c\u7136\u540e\u53c8\u4eceB\u53d8\u6210A\uff0cReact\u4f1a\u8ba4\u4e3aUI\u4e0d\u53d1\u751f\u4efb\u4f55\u53d8\u5316\uff0c\u800c\u5982\u679c\u901a\u8fc7\u624b\u52a8\u63a7\u5236\uff0c\u8fd9\u79cd\u903b\u8f91\u901a\u5e38\u662f\u6781\u5176\u590d\u6742\u7684\u3002\u5c3d\u7ba1\u6bcf\u4e00\u6b21\u90fd\u9700\u8981\u6784\u9020\u5b8c\u6574\u7684\u865a\u62dfDOM\u6811\uff0c\u4f46\u662f\u56e0\u4e3a\u865a\u62dfDOM\u662f\u5185\u5b58\u6570\u636e\uff0c\u6027\u80fd\u662f\u6781\u9ad8\u7684\uff0c\u800c\u5bf9\u5b9e\u9645DOM\u8fdb\u884c\u64cd\u4f5c\u7684\u4ec5\u4ec5\u662fDiff\u90e8\u5206\uff0c\u56e0\u800c\u80fd\u8fbe\u5230\u63d0\u9ad8\u6027\u80fd\u7684\u76ee\u7684\u3002\u8fd9\u6837\uff0c\u5728\u4fdd\u8bc1\u6027\u80fd\u7684\u540c\u65f6\uff0c\u5f00\u53d1\u8005\u5c06\u4e0d\u518d\u9700\u8981\u5173\u6ce8\u67d0\u4e2a\u6570\u636e\u7684\u53d8\u5316\u5982\u4f55\u66f4\u65b0\u5230\u4e00\u4e2a\u6216\u591a\u4e2a\u5177\u4f53\u7684DOM\u5143\u7d20\uff0c\u800c\u53ea\u9700\u8981\u5173\u5fc3\u5728\u4efb\u610f\u4e00\u4e2a\u6570\u636e\u72b6\u6001\u4e0b\uff0c\u6574\u4e2a\u754c\u9762\u662f\u5982\u4f55Render\u7684\u3002<\/p>\n<p>\u5982\u679c\u4f60\u50cf\u572890\u5e74\u4ee3\u90a3\u6837\u5199\u8fc7\u670d\u52a1\u5668\u7aefRender\u7684\u7eafWeb\u9875\u9762\u90a3\u4e48\u5e94\u8be5\u77e5\u9053\uff0c\u670d\u52a1\u5668\u7aef\u6240\u8981\u505a\u7684\u5c31\u662f\u6839\u636e\u6570\u636eRender\u51faHTML\u9001\u5230\u6d4f\u89c8\u5668\u7aef\u3002\u5982\u679c\u8fd9\u65f6\u56e0\u4e3a\u7528\u6237\u7684\u4e00\u4e2a\u70b9\u51fb\u9700\u8981\u6539\u53d8\u67d0\u4e2a\u72b6\u6001\u6587\u5b57\uff0c\u90a3\u4e48\u4e5f\u662f\u901a\u8fc7\u5237\u65b0\u6574\u4e2a\u9875\u9762\u6765\u5b8c\u6210\u7684\u3002\u670d\u52a1\u5668\u7aef\u5e76\u4e0d\u9700\u8981\u77e5\u9053\u662f\u54ea\u4e00\u5c0f\u6bb5HTML\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u800c\u53ea\u9700\u8981\u6839\u636e\u6570\u636e\u5237\u65b0\u6574\u4e2a\u9875\u9762\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u4efb\u4f55UI\u7684\u53d8\u5316\u90fd\u662f\u901a\u8fc7\u6574\u4f53\u5237\u65b0\u6765\u5b8c\u6210\u7684\u3002\u800cReact\u5c06\u8fd9\u79cd\u5f00\u53d1\u6a21\u5f0f\u4ee5\u9ad8\u6027\u80fd\u7684\u65b9\u5f0f\u5e26\u5230\u4e86\u524d\u7aef\uff0c\u6bcf\u505a\u4e00\u70b9\u754c\u9762\u7684\u66f4\u65b0\uff0c\u4f60\u90fd\u53ef\u4ee5\u8ba4\u4e3a\u5237\u65b0\u4e86\u6574\u4e2a\u9875\u9762\u3002\u81f3\u4e8e\u5982\u4f55\u8fdb\u884c\u5c40\u90e8\u66f4\u65b0\u4ee5\u4fdd\u8bc1\u6027\u80fd\uff0c\u5219\u662fReact\u6846\u67b6\u8981\u5b8c\u6210\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u501f\u7528Facebook\u4ecb\u7ecdReact\u7684\u89c6\u9891\u4e2d\u804a\u5929\u5e94\u7528\u7684\u4f8b\u5b50\uff0c\u5f53\u4e00\u6761\u65b0\u7684\u6d88\u606f\u8fc7\u6765\u65f6\uff0c\u4f20\u7edf\u5f00\u53d1\u7684\u601d\u8def\u5982\u4e0a\u56fe\uff0c\u4f60\u7684\u5f00\u53d1\u8fc7\u7a0b\u9700\u8981\u77e5\u9053\u54ea\u6761\u6570\u636e\u8fc7\u6765\u4e86\uff0c\u5982\u4f55\u5c06\u65b0\u7684DOM\u7ed3\u70b9\u6dfb\u52a0\u5230\u5f53\u524dDOM\u6811\u4e0a\uff1b\u800c\u57fa\u4e8eReact\u7684\u5f00\u53d1\u601d\u8def\u5982\u4e0b\u56fe\uff0c\u4f60\u6c38\u8fdc\u53ea\u9700\u8981\u5173\u5fc3\u6570\u636e\u6574\u4f53\uff0c\u4e24\u6b21\u6570\u636e\u4e4b\u95f4\u7684UI\u5982\u4f55\u53d8\u5316\uff0c\u5219\u5b8c\u5168\u4ea4\u7ed9\u6846\u67b6\u53bb\u505a\u3002\u53ef\u4ee5\u770b\u5230\uff0c\u4f7f\u7528React\u5927\u5927\u964d\u4f4e\u4e86\u903b\u8f91\u590d\u6742\u6027\uff0c\u610f\u5473\u7740\u5f00\u53d1\u96be\u5ea6\u964d\u4f4e\uff0c\u53ef\u80fd\u4ea7\u751fBug\u7684\u673a\u4f1a\u4e5f\u66f4\u5c11\u3002<\/p>\n<p>2\u3001\u7ec4\u4ef6\u5316<\/p>\n<p>\u865a\u62dfDOM(virtual-dom)\u4e0d\u4ec5\u5e26\u6765\u4e86\u7b80\u5355\u7684UI\u5f00\u53d1\u903b\u8f91\uff0c\u540c\u65f6\u4e5f\u5e26\u6765\u4e86\u7ec4\u4ef6\u5316\u5f00\u53d1\u7684\u601d\u60f3\uff0c\u6240\u8c13\u7ec4\u4ef6\uff0c\u5373\u5c01\u88c5\u8d77\u6765\u7684\u5177\u6709\u72ec\u7acb\u529f\u80fd\u7684UI\u90e8\u4ef6\u3002React\u63a8\u8350\u4ee5\u7ec4\u4ef6\u7684\u65b9\u5f0f\u53bb\u91cd\u65b0\u601d\u8003UI\u6784\u6210\uff0c\u5c06UI\u4e0a\u6bcf\u4e00\u4e2a\u529f\u80fd\u76f8\u5bf9\u72ec\u7acb\u7684\u6a21\u5757\u5b9a\u4e49\u6210\u7ec4\u4ef6\uff0c\u7136\u540e\u5c06\u5c0f\u7684\u7ec4\u4ef6\u901a\u8fc7\u7ec4\u5408\u6216\u8005\u5d4c\u5957\u7684\u65b9\u5f0f\u6784\u6210\u5927\u7684\u7ec4\u4ef6\uff0c\u6700\u7ec8\u5b8c\u6210\u6574\u4f53UI\u7684\u6784\u5efa\u3002\u4f8b\u5982\uff0cFacebook\u7684instagram.com\u6574\u7ad9\u90fd\u91c7\u7528\u4e86React\u6765\u5f00\u53d1\uff0c\u6574\u4e2a\u9875\u9762\u5c31\u662f\u4e00\u4e2a\u5927\u7684\u7ec4\u4ef6\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u5d4c\u5957\u7684\u5927\u91cf\u5176\u5b83\u7ec4\u4ef6\uff0c\u5927\u5bb6\u6709\u5174\u8da3\u53ef\u4ee5\u770b\u4e0b\u5b83\u80cc\u540e\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u5982\u679c\u8bf4MVC\u7684\u601d\u60f3\u8ba9\u4f60\u505a\u5230\u89c6\u56fe-\u6570\u636e-\u63a7\u5236\u5668\u7684\u5206\u79bb\uff0c\u90a3\u4e48\u7ec4\u4ef6\u5316\u7684\u601d\u8003\u65b9\u5f0f\u5219\u662f\u5e26\u6765\u4e86UI\u529f\u80fd\u6a21\u5757\u4e4b\u95f4\u7684\u5206\u79bb\u3002\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u5178\u578b\u7684Blog\u8bc4\u8bba\u754c\u9762\u6765\u770bMVC\u548c\u7ec4\u4ef6\u5316\u5f00\u53d1\u601d\u8def\u7684\u533a\u522b\u3002<\/p>\n<p>\u5bf9\u4e8eMVC\u5f00\u53d1\u6a21\u5f0f\u6765\u8bf4\uff0c\u5f00\u53d1\u8005\u5c06\u4e09\u8005\u5b9a\u4e49\u6210\u4e0d\u540c\u7684\u7c7b\uff0c\u5b9e\u73b0\u4e86\u8868\u73b0\uff0c\u6570\u636e\uff0c\u63a7\u5236\u7684\u5206\u79bb\u3002\u5f00\u53d1\u8005\u66f4\u591a\u7684\u662f\u4ece\u6280\u672f\u7684\u89d2\u5ea6\u6765\u5bf9UI\u8fdb\u884c\u62c6\u5206\uff0c\u5b9e\u73b0\u677e\u8026\u5408\u3002<\/p>\n<p>\u5bf9\u4e8eReact\u800c\u8a00\uff0c\u5219\u5b8c\u5168\u662f\u4e00\u4e2a\u65b0\u7684\u601d\u8def\uff0c\u5f00\u53d1\u8005\u4ece\u529f\u80fd\u7684\u89d2\u5ea6\u51fa\u53d1\uff0c\u5c06UI\u5206\u6210\u4e0d\u540c\u7684\u7ec4\u4ef6\uff0c\u6bcf\u4e2a\u7ec4\u4ef6\u90fd\u72ec\u7acb\u5c01\u88c5\u3002<\/p>\n<p>\u5728React\u4e2d\uff0c\u4f60\u6309\u7167\u754c\u9762\u6a21\u5757\u81ea\u7136\u5212\u5206\u7684\u65b9\u5f0f\u6765\u7ec4\u7ec7\u548c\u7f16\u5199\u4f60\u7684\u4ee3\u7801\uff0c\u5bf9\u4e8e\u8bc4\u8bba\u754c\u9762\u800c\u8a00\uff0c\u6574\u4e2aUI\u662f\u4e00\u4e2a\u901a\u8fc7\u5c0f\u7ec4\u4ef6\u6784\u6210\u7684\u5927\u7ec4\u4ef6\uff0c\u6bcf\u4e2a\u7ec4\u4ef6\u53ea\u5173\u5fc3\u81ea\u5df1\u90e8\u5206\u7684\u903b\u8f91\uff0c\u5f7c\u6b64\u72ec\u7acb\u3002<\/p>\n<p>React\u8ba4\u4e3a\u4e00\u4e2a\u7ec4\u4ef6\u5e94\u8be5\u5177\u6709\u5982\u4e0b\u7279\u5f81\uff1a<\/p>\n<p>\uff081\uff09\u53ef\u7ec4\u5408\uff08Composeable\uff09\uff1a\u4e00\u4e2a\u7ec4\u4ef6\u6613\u4e8e\u548c\u5176\u5b83\u7ec4\u4ef6\u4e00\u8d77\u4f7f\u7528\uff0c\u6216\u8005\u5d4c\u5957\u5728\u53e6\u4e00\u4e2a\u7ec4\u4ef6\u5185\u90e8\u3002\u5982\u679c\u4e00\u4e2a\u7ec4\u4ef6\u5185\u90e8\u521b\u5efa\u4e86\u53e6\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u90a3\u4e48\u8bf4\u7236\u7ec4\u4ef6\u62e5\u6709\uff08own\uff09\u5b83\u521b\u5efa\u7684\u5b50\u7ec4\u4ef6\uff0c\u901a\u8fc7\u8fd9\u4e2a\u7279\u6027\uff0c\u4e00\u4e2a\u590d\u6742\u7684UI\u53ef\u4ee5\u62c6\u5206\u6210\u591a\u4e2a\u7b80\u5355\u7684UI\u7ec4\u4ef6\uff1b<\/p>\n<p>\uff082\uff09\u53ef\u91cd\u7528\uff08Reusable\uff09\uff1a\u6bcf\u4e2a\u7ec4\u4ef6\u90fd\u662f\u5177\u6709\u72ec\u7acb\u529f\u80fd\u7684\uff0c\u5b83\u53ef\u4ee5\u88ab\u4f7f\u7528\u5728\u591a\u4e2aUI\u573a\u666f\uff1b<\/p>\n<p>\uff083\uff09\u53ef\u7ef4\u62a4\uff08Maintainable\uff09\uff1a\u6bcf\u4e2a\u5c0f\u7684\u7ec4\u4ef6\u4ec5\u4ec5\u5305\u542b\u81ea\u8eab\u7684\u903b\u8f91\uff0c\u66f4\u5bb9\u6613\u88ab\u7406\u89e3\u548c\u7ef4\u62a4\uff1b<\/p>\n<p>\u4e8c\u3001\u4e0b\u8f7dReactJS\uff0c\u7f16\u5199Hello\uff0cworld<\/p>\n<p>ReactJs\u4e0b\u8f7d\u975e\u5e38\u7b80\u5355\uff0c\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u4e0b\u8f7d\uff0c\u8fd9\u91cc\u518d\u4e00\u6b21\u7ed9\u51fa\u4e0b\u8f7d\u5730\u5740http:\/\/facebook.github.io\/react\/downloads.html,\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u6211\u4e48\u770b\u5230\u7684\u662f\u4e00\u4e2a\u538b\u7f29\u5305\u3002\u89e3\u538b\u540e\uff0c\u6211\u4eec\u65b0\u5efa\u4e00\u4e2ahtml\u6587\u4ef6\uff0c\u5f15\u7528react.js\u548cJSXTransformer.js\u8fd9\u4e24\u4e2ajs\u6587\u4ef6\u3002html\u6a21\u677f\u5982\u4e0b(js\u8def\u5f84\u6539\u6210\u81ea\u5df1\u7684):<\/p>\n<p>&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&nbsp; &lt;head&gt;<\/p>\n<p>&nbsp; &nbsp; &lt;script src=&#8221;build\/react.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>&nbsp; &nbsp; &lt;script src=&#8221;build\/JSXTransformer.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>&nbsp; &lt;\/head&gt;<\/p>\n<p>&nbsp; &lt;body&gt;<\/p>\n<p>&nbsp; &nbsp; &lt;div id=&#8221;container&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>&nbsp; &nbsp; &lt;script type=&#8221;text\/jsx&#8221;&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; \/\/ ** Our code goes here! **<\/p>\n<p>&nbsp; &nbsp; &lt;\/script&gt;<\/p>\n<p>&nbsp; &lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;<\/p>\n<p>\u8fd9\u91cc\u5927\u5bb6\u53ef\u80fd\u4f1a\u5947\u602a\uff0c\u4e3a\u4ec0\u4e48script\u7684type\u662ftext\/jsx,\u8fd9\u662f\u56e0\u4e3a React \u72ec\u6709\u7684 JSX \u8bed\u6cd5\uff0c\u8ddf JavaScript \u4e0d\u517c\u5bb9\u3002\u51e1\u662f\u4f7f\u7528 JSX \u7684\u5730\u65b9\uff0c\u90fd\u8981\u52a0\u4e0a type=&#8221;text\/jsx&#8221; \u3002 \u5176\u6b21\uff0cReact \u63d0\u4f9b\u4e24\u4e2a\u5e93\uff1a react.js \u548c JSXTransformer.js \uff0c\u5b83\u4eec\u5fc5\u987b\u9996\u5148\u52a0\u8f7d\u3002\u5176\u4e2d\uff0cJSXTransformer.js \u7684\u4f5c\u7528\u662f\u5c06 JSX \u8bed\u6cd5\u8f6c\u4e3a JavaScript \u8bed\u6cd5\u3002\u8fd9\u4e00\u6b65\u5f88\u6d88\u8017\u65f6\u95f4\uff0c\u5b9e\u9645\u4e0a\u7ebf\u7684\u65f6\u5019\uff0c\u5e94\u8be5\u5c06\u5b83\u653e\u5230\u670d\u52a1\u5668\u5b8c\u6210\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\u4e86\uff0c\u9996\u5148\u6211\u4eec\u5148\u6765\u8ba4\u8bc6\u4e00\u4e0bReactJs\u91cc\u9762\u7684React.render\u65b9\u6cd5\uff1a<\/p>\n<p>React.render \u662f React \u7684\u6700\u57fa\u672c\u65b9\u6cd5\uff0c\u7528\u4e8e\u5c06\u6a21\u677f\u8f6c\u4e3a HTML \u8bed\u8a00\uff0c\u5e76\u63d2\u5165\u6307\u5b9a\u7684 DOM \u8282\u70b9\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u5728script\u6807\u7b7e\u91cc\u9762\u7f16\u5199\u4ee3\u7801\uff0c\u6765\u8f93\u51faHello\uff0cworld\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Hello, world!&lt;\/h1&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0creact\u5e76\u4e0d\u4f9d\u8d56jQuery\uff0c\u5f53\u7136\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528jQuery\uff0c\u4f46\u662frender\u91cc\u9762\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f7f\u7528JavaScript\u539f\u751f\u7684getElementByID\u65b9\u6cd5\uff0c\u4e0d\u80fd\u4f7f\u7528jQuery\u6765\u9009\u53d6DOM\u8282\u70b9\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5728\u6d4f\u89c8\u5668\u6253\u5f00\u8fd9\u4e2a\u9875\u9762\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u6d4f\u89c8\u5668\u663e\u793a\u4e00\u4e2a\u5927\u5927\u7684Hello\uff0cworld,\u56e0\u4e3a\u6211\u4eec\u7528\u4e86&lt;h1&gt;\u6807\u7b7e\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u606d\u559c\uff0c\u4f60\u5df2\u7ecf\u6b65\u5165\u4e86ReactJS\u7684\u5927\u95e8~~\u4e0b\u9762\uff0c\u8ba9\u6211\u4eec\u6765\u8fdb\u4e00\u6b65\u5b66\u4e60ReactJs\u5427~~<\/p>\n<p>\u4e09\u3001Jsx\u8bed\u6cd5<\/p>\n<p>HTML \u8bed\u8a00\u76f4\u63a5\u5199\u5728 JavaScript \u8bed\u8a00\u4e4b\u4e2d\uff0c\u4e0d\u52a0\u4efb\u4f55\u5f15\u53f7\uff0c\u8fd9\u5c31\u662f JSX \u7684\u8bed\u6cd5\uff0c\u5b83\u5141\u8bb8 HTML \u4e0e JavaScript \u7684\u6df7\u5199\uff0c\u4e86\u89e3\u8fc7AngularJs\u7684\u770b\u5230\u4e0b\u9762\u7684\u4ee3\u7801\u4e00\u5b9a\u4f1a\u611f\u89c9\u5f88\u719f\u6089\u7684\uff0c\u6211\u4eec\u6765\u770b\u4ee3\u7801\uff1a<\/p>\n<p>var names = [&#8216;Jack&#8217;, &#8216;Tom&#8217;, &#8216;Alice&#8217;];<\/p>\n<p>&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names.map(function (name) {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &lt;div&gt;Hello, {name}!&lt;\/div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; })<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;,<\/p>\n<p>&nbsp; &nbsp;document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u58f0\u660e\u4e86\u4e00\u4e2anames\u6570\u7ec4\uff0c\u7136\u540e\u904d\u5386\u5728\u524d\u9762\u52a0\u4e0aHello,\u8f93\u51fa\u5230DOM\u4e2d\uff0c\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p>JSX \u5141\u8bb8\u76f4\u63a5\u5728\u6a21\u677f\u63d2\u5165 JavaScript \u53d8\u91cf\u3002\u5982\u679c\u8fd9\u4e2a\u53d8\u91cf\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u5219\u4f1a\u5c55\u5f00\u8fd9\u4e2a\u6570\u7ec4\u7684\u6240\u6709\u6210\u5458\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>var arr = [<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;h1&gt;Hello world!&lt;\/h1&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;h2&gt;React is perfect!&lt;\/h2&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; ];<\/p>\n<p>&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;*{arr}*&lt;\/div&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u663e\u793a\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u8fd9\u91cc\u7684\u661f\u53f7\u53ea\u662f\u505a\u6807\u8bc6\u7528\u7684\uff0c\u5927\u5bb6\u4e0d\u8981\u88ab\u5979\u8ff7\u60d1\u4e86~~<\/p>\n<p>\u4f60\u770b\u5230\u8fd9\u91cc\uff0c\u8bf4\u660e\u4f60\u5bf9React\u8fd8\u662f\u86ee\u611f\u5174\u8da3\u7684\uff0c\u606d\u559c\u4f60\uff0c\u575a\u6301\u4e0b\u6765\u4e86\uff0c\u90a3\u4e48\u4e0b\u9762\uff0c\u6211\u4eec\u5f00\u59cb\u5b66\u4e60React\u91cc\u9762\u7684&#8221;\u771f\u529f\u592b&#8221;\u4e86~~ Are\u3000you ready?<\/p>\n<p>\u56db\u3001ReactJS\u7ec4\u4ef6<\/p>\n<p>1\u3001\u7ec4\u4ef6\u5c5e\u6027&nbsp;<\/p>\n<p>\u524d\u9762\u8bf4\u4e86\uff0cReactJS\u662f\u57fa\u4e8e\u7ec4\u4ef6\u5316\u7684\u5f00\u53d1\uff0c\u4e0b\u9762\u6211\u4eec\u5f00\u59cb\u6765\u5b66\u4e60ReactJS\u91cc\u9762\u7684\u7ec4\u4ef6\uff0cReact \u5141\u8bb8\u5c06\u4ee3\u7801\u5c01\u88c5\u6210\u7ec4\u4ef6\uff08component\uff09\uff0c\u7136\u540e\u50cf\u63d2\u5165\u666e\u901a HTML \u6807\u7b7e\u4e00\u6837\uff0c\u5728\u7f51\u9875\u4e2d\u63d2\u5165\u8fd9\u4e2a\u7ec4\u4ef6\u3002React.createClass \u65b9\u6cd5\u5c31\u7528\u4e8e\u751f\u6210\u4e00\u4e2a\u7ec4\u4ef6\u7c7b\u3002<\/p>\n<p>\u4e0b\u9762\uff0c\u6211\u4eec\u6765\u7f16\u5199\u7b2c\u4e00\u4e2a\u7ec4\u4ef6Greet\uff0c\u6709\u4e00\u4e2aname\u5c5e\u6027\uff0c\u7136\u540e\u8f93\u51fahello + name\u7684\u503c\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>var Greet = React.createClass({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; render: function() {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return &lt;h1&gt;Hello {this.props.name}&lt;\/h1&gt;;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; });<\/p>\n<p>&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;Greet name=&#8221;Jack&#8221; \/&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u770b\u5230\u8fd9\u6bb5\u4ee3\u7801\uff0c\u63a5\u89e6\u8fc7AngularJS\u7684\u670b\u53cb\u4eec\u662f\u4e0d\u662f\u6709\u4e00\u79cd\u719f\u6089\u7684\u611f\u89c9\uff0c\u4e0d\u8fc7\u8fd9\u91cc\u6709\u51e0\u70b9\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<p>1\u3001\u83b7\u53d6\u5c5e\u6027\u7684\u503c\u7528\u7684\u662fthis.props.\u5c5e\u6027\u540d<\/p>\n<p>2\u3001\u521b\u5efa\u7684\u7ec4\u4ef6\u540d\u79f0\u9996\u5b57\u6bcd\u5fc5\u987b\u5927\u5199\u3002<\/p>\n<p>3\u3001\u4e3a\u5143\u7d20\u6dfb\u52a0css\u7684class\u65f6\uff0c\u8981\u7528className.<\/p>\n<p>4\u3001\u7ec4\u4ef6\u7684style\u5c5e\u6027\u7684\u8bbe\u7f6e\u65b9\u5f0f\u4e5f\u503c\u5f97\u6ce8\u610f\uff0c\u8981\u5199\u6210style={{width: this.state.witdh}}<\/p>\n<p>2\u3001\u7ec4\u4ef6\u72b6\u6001<\/p>\n<p>\u7ec4\u4ef6\u514d\u4e0d\u4e86\u8981\u4e0e\u7528\u6237\u4e92\u52a8\uff0cReact \u7684\u4e00\u5927\u521b\u65b0\uff0c\u5c31\u662f\u5c06\u7ec4\u4ef6\u770b\u6210\u662f\u4e00\u4e2a\u72b6\u6001\u673a\uff0c\u4e00\u5f00\u59cb\u6709\u4e00\u4e2a\u521d\u59cb\u72b6\u6001\uff0c\u7136\u540e\u7528\u6237\u4e92\u52a8\uff0c\u5bfc\u81f4\u72b6\u6001\u53d8\u5316\uff0c\u4ece\u800c\u89e6\u53d1\u91cd\u65b0\u6e32\u67d3 UI \u3002\u4e0b\u9762\u6211\u4eec\u6765\u7f16\u5199\u4e00\u4e2a\u5c0f\u4f8b\u5b50\uff0c\u4e00\u4e2a\u6587\u672c\u6846\u548c\u4e00\u4e2abutton\uff0c\u901a\u8fc7\u70b9\u51fbbutton\u53ef\u4ee5\u6539\u53d8\u6587\u672c\u6846\u7684\u7f16\u8f91\u72b6\u6001\uff0c\u7981\u6b62\u7f16\u8f91\u548c\u5141\u8bb8\u7f16\u8f91\u3002\u901a\u8fc7\u8fd9\u4e2a\u4f8b\u5b50\u6765\u7406\u89e3ReactJS\u7684\u72b6\u6001\u673a\u5236\u3002\u5148\u770b\u4ee3\u7801\uff1a<\/p>\n<p>var InputState = React.createClass({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; getInitialState: function() {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return {enable: false};<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; },<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; handleClick: function(event) {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.setState({enable: !this.state.enable});<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; },<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; render: function() {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;input type=&#8221;text&#8221; disabled={this.state.enable} \/&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;button onClick={this.handleClick}&gt;Change State&lt;\/button&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/p&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; });<\/p>\n<p>&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;InputState \/&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u8fd9\u91cc\uff0c\u6211\u4eec\u53c8\u4f7f\u7528\u5230\u4e86\u4e00\u4e2a\u65b9\u6cd5getInitialState,\u8fd9\u4e2a\u51fd\u6570\u5728\u7ec4\u4ef6\u521d\u59cb\u5316\u7684\u65f6\u5019\u6267\u884c\uff0c\u5fc5\u9700\u8fd4\u56deNULL\u6216\u8005\u4e00\u4e2a\u5bf9\u8c61\u3002\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7this.state.\u5c5e\u6027\u540d\u6765\u8bbf\u95ee\u5c5e\u6027\u503c\uff0c\u8fd9\u91cc\u6211\u4eec\u5c06enable\u8fd9\u4e2a\u503c\u8ddfinput\u7684disabled\u7ed1\u5b9a\uff0c\u5f53\u8981\u4fee\u6539\u8fd9\u4e2a\u5c5e\u6027\u503c\u65f6\uff0c\u8981\u4f7f\u7528setState\u65b9\u6cd5\u3002\u6211\u4eec\u58f0\u660ehandleClick\u65b9\u6cd5\uff0c\u6765\u7ed1\u5b9a\u5230button\u4e0a\u9762\uff0c\u5b9e\u73b0\u6539\u53d8state.enable\u7684\u503c.\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p>\u539f\u7406\u5206\u6790\uff1a<\/p>\n<p>\u5f53\u7528\u6237\u70b9\u51fb\u7ec4\u4ef6\uff0c\u5bfc\u81f4\u72b6\u6001\u53d8\u5316\uff0cthis.setState \u65b9\u6cd5\u5c31\u4fee\u6539\u72b6\u6001\u503c\uff0c\u6bcf\u6b21\u4fee\u6539\u4ee5\u540e\uff0c\u81ea\u52a8\u8c03\u7528 this.render \u65b9\u6cd5\uff0c\u518d\u6b21\u6e32\u67d3\u7ec4\u4ef6\u3002<\/p>\n<p>\u8fd9\u91cc\u503c\u5f97\u6ce8\u610f\u7684\u51e0\u70b9\u5982\u4e0b\uff1a<\/p>\n<p>1\u3001getInitialState\u51fd\u6570\u5fc5\u987b\u6709\u8fd4\u56de\u503c\uff0c\u53ef\u4ee5\u662fNULL\u6216\u8005\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n<p>2\u3001\u8bbf\u95eestate\u7684\u65b9\u6cd5\u662fthis.state.\u5c5e\u6027\u540d\u3002<\/p>\n<p>3\u3001\u53d8\u91cf\u7528{}\u5305\u88f9\uff0c\u4e0d\u9700\u8981\u518d\u52a0\u53cc\u5f15\u53f7\u3002<\/p>\n<p>3\u3001\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f<\/p>\n<p>\u7ec4\u4ef6\u7684\u751f\u547d\u5468\u671f\u5206\u6210\u4e09\u4e2a\u72b6\u6001\uff1a<\/p>\n<p>Mounting\uff1a\u5df2\u63d2\u5165\u771f\u5b9e DOM<\/p>\n<p>Updating\uff1a\u6b63\u5728\u88ab\u91cd\u65b0\u6e32\u67d3<\/p>\n<p>Unmounting\uff1a\u5df2\u79fb\u51fa\u771f\u5b9e DOM<\/p>\n<p>React \u4e3a\u6bcf\u4e2a\u72b6\u6001\u90fd\u63d0\u4f9b\u4e86\u4e24\u79cd\u5904\u7406\u51fd\u6570\uff0cwill \u51fd\u6570\u5728\u8fdb\u5165\u72b6\u6001\u4e4b\u524d\u8c03\u7528\uff0cdid \u51fd\u6570\u5728\u8fdb\u5165\u72b6\u6001\u4e4b\u540e\u8c03\u7528\uff0c\u4e09\u79cd\u72b6\u6001\u5171\u8ba1\u4e94\u79cd\u5904\u7406\u51fd\u6570\u3002<\/p>\n<p>componentWillMount()<\/p>\n<p>componentDidMount()<\/p>\n<p>componentWillUpdate(object nextProps, object nextState)<\/p>\n<p>componentDidUpdate(object prevProps, object prevState)<\/p>\n<p>componentWillUnmount()<\/p>\n<p>\u6b64\u5916\uff0cReact \u8fd8\u63d0\u4f9b\u4e24\u79cd\u7279\u6b8a\u72b6\u6001\u7684\u5904\u7406\u51fd\u6570\u3002<\/p>\n<p>componentWillReceiveProps(object nextProps)\uff1a\u5df2\u52a0\u8f7d\u7ec4\u4ef6\u6536\u5230\u65b0\u7684\u53c2\u6570\u65f6\u8c03\u7528<\/p>\n<p>shouldComponentUpdate(object nextProps, object nextState)\uff1a\u7ec4\u4ef6\u5224\u65ad\u662f\u5426\u91cd\u65b0\u6e32\u67d3\u65f6\u8c03\u7528<\/p>\n<p>\u4e0b\u9762\u6765\u770b\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<p>var Hello = React.createClass({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; getInitialState: function () {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity: 1.0<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; },<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; componentDidMount: function () {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.timer = setInterval(function () {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var opacity = this.state.opacity;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity -= .05;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (opacity &lt; 0.1) {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity = 1.0;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.setState({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; opacity: opacity<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }.bind(this), 100);<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; },<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; render: function () {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div style={{opacity: this.state.opacity}}&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hello {this.props.name}<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; });<br \/>\n&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;Hello name=&#8221;world&#8221;\/&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.body<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u4e0a\u9762\u4ee3\u7801\u5728hello\u7ec4\u4ef6\u52a0\u8f7d\u4ee5\u540e\uff0c\u901a\u8fc7 componentDidMount \u65b9\u6cd5\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u6bcf\u9694100\u6beb\u79d2\uff0c\u5c31\u91cd\u65b0\u8bbe\u7f6e\u7ec4\u4ef6\u7684\u900f\u660e\u5ea6\uff0c\u4ece\u800c\u5f15\u53d1\u91cd\u65b0\u6e32\u67d3\u3002<\/p>\n<p>4\u3001\u7ec4\u4ef6\u7684\u5d4c\u5957<\/p>\n<p>React\u662f\u57fa\u4e8e\u7ec4\u4ef6\u5316\u7684\u5f00\u53d1\uff0c\u90a3\u4e48\u7ec4\u4ef6\u5316\u5f00\u53d1\u6700\u5927\u7684\u4f18\u70b9\u662f\u4ec0\u4e48\uff1f\u6beb\u65e0\u7591\u95ee\uff0c\u5f53\u7136\u662f\u590d\u7528\uff0c\u4e0b\u9762\u6211\u4eec\u6765\u770b\u770bReact\u4e2d\u5230\u5e95\u662f\u5982\u4f55\u5b9e\u73b0\u7ec4\u4ef6\u7684\u590d\u7528\u7684\uff0c\u8fd9\u91cc\u6211\u4eec\u8fd8\u5199\u4e00\u4e2a\u4f8b\u5b50\u6765\u8bf4\u5427\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>var Search = React.createClass({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; render: function() {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{this.props.searchType}:&lt;input type=&#8221;text&#8221; \/&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;button&gt;Search&lt;\/button&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; });<\/p>\n<p>&nbsp; &nbsp; &nbsp; var Page = React.createClass({<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; render: function() {<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return (<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;h1&gt;Welcome!&lt;\/h1&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Search searchType=&#8221;Title&#8221; \/&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Search &nbsp;searchType=&#8221;Content&#8221; \/&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;\/div&gt;<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n<p>&nbsp; &nbsp; &nbsp; });<\/p>\n<p>&nbsp; &nbsp; &nbsp; React.render(<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &lt;Page \/&gt;,<\/p>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById(&#8216;container&#8217;)<\/p>\n<p>&nbsp; &nbsp; &nbsp; );<\/p>\n<p>\u8fd9\u91cc\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aSearch\u7ec4\u4ef6\uff0c\u7136\u540e\u53c8\u521b\u5efa\u4e86\u4e00\u4e2aPage\u7ec4\u4ef6\uff0c\u7136\u540e\u6211\u4eec\u5728Page\u7ec4\u4ef6\u4e2d\u8c03\u7528Search\u7ec4\u4ef6\uff0c\u5e76\u4e14\u8c03\u7528\u4e86\u4e24\u6b21\uff0c\u8fd9\u91cc\u6211\u4eec\u901a\u8fc7\u5c5e\u6027searchType\u4f20\u5165\u503c<\/p>\n<p>\u4e94\u3001ReactJs\u5c0f\u7ed3<\/p>\n<p>\u5173\u4e8eReactJS\u4eca\u5929\u5c31\u5148\u5b66\u4e60\u5230\u8fd9\u91cc\u4e86\uff0c\u4e0b\u9762\u6765\u603b\u7ed3\u4e00\u4e0b\uff0c\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<p>1\u3001ReactJs\u662f\u57fa\u4e8e\u7ec4\u4ef6\u5316\u7684\u5f00\u53d1\uff0c\u6240\u4ee5\u6700\u7ec8\u4f60\u7684\u9875\u9762\u5e94\u8be5\u662f\u7531\u82e5\u5e72\u4e2a\u5c0f\u7ec4\u4ef6\u7ec4\u6210\u7684\u5927\u7ec4\u4ef6\u3002<\/p>\n<p>2\u3001\u53ef\u4ee5\u901a\u8fc7\u5c5e\u6027\uff0c\u5c06\u503c\u4f20\u9012\u5230\u7ec4\u4ef6\u5185\u90e8\uff0c\u540c\u7406\u4e5f\u53ef\u4ee5\u901a\u8fc7\u5c5e\u6027\u5c06\u5185\u90e8\u7684\u7ed3\u679c\u4f20\u9012\u5230\u7236\u7ea7\u7ec4\u4ef6(\u7559\u7ed9\u5927\u5bb6\u7814\u7a76)\uff1b\u8981\u5bf9\u67d0\u4e9b\u503c\u7684\u53d8\u5316\u505aDOM\u64cd\u4f5c\u7684\uff0c\u8981\u628a\u8fd9\u4e9b\u503c\u653e\u5230state\u4e2d\u3002<\/p>\n<p>3\u3001\u4e3a\u7ec4\u4ef6\u6dfb\u52a0\u5916\u90e8css\u6837\u5f0f\u65f6\uff0c\u7c7b\u540d\u5e94\u8be5\u5199\u6210className\u800c\u4e0d\u662fclass;\u6dfb\u52a0\u5185\u90e8\u6837\u5f0f\u65f6\uff0c\u5e94\u8be5\u662fstyle={{opacity: this.state.opacity}}\u800c\u4e0d\u662fstyle=&#8221;opacity:{this.state.opacity};&#8221;\u3002<\/p>\n<p>4\u3001\u7ec4\u4ef6\u540d\u79f0\u9996\u5b57\u6bcd\u5fc5\u987b\u5927\u5199\u3002<\/p>\n<p>5\u3001\u53d8\u91cf\u540d\u7528{}\u5305\u88f9\uff0c\u4e14\u4e0d\u80fd\u52a0\u53cc\u5f15\u53f7\u3002<\/p>\n<p>\u516d\u3001\u53c2\u8003\u8d44\u6599<\/p>\n<p>React\u4e2d\u6587\u6587\u6863 &nbsp;http:\/\/reactjs.cn\/<\/p>\n<p>React \u5165\u95e8\u5b9e\u4f8b\u6559\u7a0b &nbsp; &nbsp;http:\/\/www.ruanyifeng.com\/blog\/2015\/03\/react.html<\/p>\n<p class=\"post-copyright\">\u6b22\u8fce\u5206\u4eab\u672c\u6587\uff0c\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u51fa\u5904\uff1a<a href=\"http:\/\/www.qdabc.cn\">\u524d\u7aefABC<\/a> &raquo; <a href=\"http:\/\/www.qdabc.cn\/?p=692\">ReactJs \u5165\u95e8\u6559\u7a0b<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>\u73b0\u5728\u6700\u70ed\u95e8\u7684\u524d\u7aef\u6846\u67b6\u6709AngularJS\u3001React\u3001Bootstrap\u7b49\u3002\u81ea\u4ece\u63a5\u89e6\u4e86ReactJS\uff0cReactJs\u7684\u865a\u62dfDOM\uff08Virtual DOM\uff09\u548c\u7ec4\u4ef6\u5316\u7684\u5f00\u53d1\u6df1\u6df1\u7684\u5438\u5f15\u4e86\u6211\uff0c\u4e0b\u9762\u6765\u8ddf\u6211\u4e00\u8d77\u9886 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":319,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/692"}],"collection":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=692"}],"version-history":[{"count":2,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/692\/revisions"}],"predecessor-version":[{"id":694,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/posts\/692\/revisions\/694"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=\/wp\/v2\/media\/319"}],"wp:attachment":[{"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.qdabc.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}