{"id":1473,"date":"2021-06-30T20:54:00","date_gmt":"2021-06-30T12:54:00","guid":{"rendered":"https:\/\/www.7gugu.com\/?p=1473"},"modified":"2021-06-30T20:54:00","modified_gmt":"2021-06-30T12:54:00","slug":"react%e8%84%9a%e6%89%8b%e6%9e%b6v1-0","status":"publish","type":"post","link":"https:\/\/7gugu.com\/index.php\/2021\/06\/30\/react%e8%84%9a%e6%89%8b%e6%9e%b6v1-0\/","title":{"rendered":"React\u811a\u624b\u67b6V1.0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u80cc\u666f<\/h2>\n\n\n\n<p>\u6700\u8fd1\u5f00\u59cb\u636f\u996cReact\uff0c\u60f3\u7740\u5b66\u4f1a\u4e86React\u5c31\u80fd\u628aReact Native\u7ed9\u5b66\u4e60\u4e86\uff0c\u7136\u540e\u5c31\u80fd\u5199App\u3002\u4e3a\u4e86\u80fd\u591f\u5728React Native\u4e0a\u5c11\u8e29\u5751\uff0c\u6211\u642d\u5efa\u8fd9\u4e2a\u811a\u624b\u67b6\u4e4b\u540e\uff0c\u51c6\u5907\u5f00\u53d1\u4e00\u4e2a\u535a\u6587\u53d1\u5e03\u7cfb\u7edf\uff0c\u4f5c\u4e3aDEMO\u7ec3\u7ec3\u624b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f9d\u8d56\u6784\u6210<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>React\u6838\u5fc3<\/li><li>React-router-dom \u8def\u7531<\/li><li>Redux \u72b6\u6001\u7ba1\u7406<\/li><li>ESlint \u4ee3\u7801\u683c\u5f0f\u7ba1\u7406<\/li><li>Vite \u6253\u5305\u5de5\u5177<\/li><li>Axios \u7f51\u7edc\u8bf7\u6c42\u5e93<\/li><li>Antd UI\u5e93<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u642d\u5efa\u6d41\u7a0b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u521d\u59cb\u5316React<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1.1 \u6a21\u677f\u521d\u59cb\u5316<\/h4>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528Vite\u81ea\u5e26\u7684\u6a21\u677f\uff0c\u521d\u59cb\u5316React\uff0c\u5728\u672c\u6559\u7a0b\u4e2d\u6211\u4f7f\u7528\u7684\u662ftemplate\u6307\u4ee4\u6765\u521d\u59cb\u5316\u9879\u76ee\u3002<\/p>\n\n\n\n<p>\u8fd0\u884c\u4ee5\u4e0b\u6307\u4ee4\u521d\u59cb\u5316\u9879\u76ee<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;# npm 6.0<br>&nbsp;npm init @vitejs\/app gublog(\u9879\u76ee\u540d\u79f0) --template react(\u6a21\u677f\u540d\u79f0)<br>&nbsp;\u200b<br>&nbsp;# npm 7.0+ (\u9700\u8981\u989d\u5916\u7684\u53cc\u6a2a\u7ebf)<br>&nbsp;npm init @vitejs\/app gublog(\u9879\u76ee\u540d\u79f0) --(\u989d\u5916\u7684\u53cc\u6a2a\u7ebf) --template react(\u6a21\u677f\u540d\u79f0)<\/pre>\n\n\n\n<p>\u8fd0\u884c\u6307\u4ee4\u540e\uff0cnpm\u5c06\u521b\u5efa\u4e00\u4e2a\u4ee5\u9879\u76ee\u540d\u79f0\u547d\u540d\u7684\u6587\u4ef6\u5939\ud83d\udcc1\uff0c\u6765\u521d\u59cb\u5316\u9879\u76ee\u3002<\/p>\n\n\n\n<p>\u521d\u59cb\u5316\u5b8c\u6210\u540e\u7684\u6587\u4ef6\u6811\u7ed3\u6784\u4e3a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;root<br>&nbsp;\u2514\u2500\u2500 gublog(\u9879\u76ee\u540d\u79f0)<br>&nbsp; &nbsp;  \u251c\u2500\u2500 dist<br>&nbsp; &nbsp;  \u251c\u2500\u2500 node_modules<br>&nbsp; &nbsp;  \u251c\u2500\u2500 src<br>&nbsp; &nbsp;  \u251c\u2500\u2500 index.html<br>&nbsp; &nbsp;  \u251c\u2500\u2500 package-lock.json<br>&nbsp; &nbsp;  \u251c\u2500\u2500 package.json<br>&nbsp; &nbsp;  \u2514\u2500\u2500 vite.config.js<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">1.2 \u542f\u52a8\u73af\u5883<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>cd \u9879\u76ee\u6587\u4ef6\u5939<\/li><li>npm install #\u4e0b\u8f7d\u4f9d\u8d56<\/li><li>npm run dev #\u542f\u52a8\u5f00\u53d1\u73af\u5883<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img decoding=\"async\" src=\"https:\/\/www.7gugu.com\/wp-content\/uploads\/2021\/06\/2021062916250225-scaled.jpg\" alt=\"\u73af\u5883\u542f\u52a8\u6210\u529f\"\/><\/figure>\n\n\n\n<p>\u51fa\u73b0\u4e0a\u56fe\u7684\u7f51\u9875\u65f6\uff0c\u6211\u4eec\u5c31\u5df2\u7ecf\u642d\u5efa\u51fa<code>Vite<\/code> + <code>React<\/code>\u7684\u5f00\u53d1\u73af\u5883<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u5b89\u88c5React-router-dom<\/h3>\n\n\n\n<p>\u4e3a\u4e86\u80fd\u591f\u5b9e\u73b0\u65e0\u5237\u65b0\u5207\u6362\u9875\u9762\uff0c\u6b64\u5904\u6211\u7684\u811a\u624b\u67b6\u4e5f\u4f1a\u5f15\u5165\u5b98\u65b9\u63d0\u4f9b\u7684Router\u6765\u505a\u524d\u7aef\u8def\u7531\u7ba1\u7406\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.1 \u5b89\u88c5\u4f9d\u8d56<\/h4>\n\n\n\n<p>\u8fd0\u884c\u6307\u4ee4\u5b89\u88c5\u8def\u7531\u7ec4\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;npm install react-router-dom --save-dev<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">2.2 \u6ce8\u610f\u26a0\ufe0f<\/h4>\n\n\n\n<p>React-Router-Dom\u5c31\u662fReact Router V4\u7684\u6d4f\u89c8\u5668\u7248\u672c\uff0c\u539f\u6765\u6587\u6863\u7684Router\u8981\u88ab\u66ff\u6362\u6210BrowserRouter\u624d\u80fd\u4f7f\u7528\u3002\u4e3a\u4e86\u4e0d\u4f7f\u7528\u65b9\u9762\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>as<\/code>\u5173\u952e\u5b57\u6765\u4fee\u6539\u522b\u540d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;import 'BrowserRouter' as 'Router' from 'react-router-dom'<\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6211\u771f\u7684\u5f88\u60f3\u5410\u69fd\uff0c\u641e\u4e00\u4e2aReact-Router\u5c31\u597d\u4e86\u561b\ud83e\udd37\u200d\u2642\ufe0f\uff0c\u5e72\u561b\u8fd8\u641e\u4e00\u4e2aReact-Router-Dom\u3002\u8fd9\u4e1c\u897f\u672c\u8d28\u4e0a\u5c31\u662f\u5957\u5a03\u518d\u5c01\u88c5\ud83d\udce6\u3002\u800c\u4e14\u6700\u8fd1\u7684V4\u7248\u672c\u8fd8\u820d\u5f03\u4e86\u65e7\u7684Router\u6807\u7b7e\uff0c\u6539\u6210\u4e86BrowserRouter\u3002\u771f\u7684\u662fNT\u3002<\/p>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6cd5\u6765\u6e90\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/stackoverflow.com\/questions\/43008036\/the-prop-history-is-marked-as-required-in-router-but-its-value-is-undefine\">https:\/\/stackoverflow.com\/questions\/43008036\/the-prop-history-is-marked-as-required-in-router-but-its-value-is-undefine<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u5b89\u88c5Redux<\/h3>\n\n\n\n<p>\u5b89\u88c5Redux\u4e3b\u8981\u662f\u4e3a\u4e86\u4f7f\u5f97\u7ec4\u4ef6\u7684\u8026\u5408\u964d\u4f4e\uff0c\u4f7f\u5f97\u66f4\u5bb9\u6613\u7684\u7ba1\u7406\u72b6\u6001\uff0c\u56e0\u6b64\u88ab\u6253\u5305\u5230\u811a\u624b\u67b6\u5f53\u4e2d\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3.1 \u5b89\u88c5\u4f9d\u8d56<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;npm install redux --save-dev<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u5b89\u88c5ESlint<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">4.1 \u5b89\u88c5\u4f9d\u8d56<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;npm install eslint --save-dev<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u5b89\u88c5Axios\u7f51\u7edc\u8bf7\u6c42\u5e93<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">5.1 \u5b89\u88c5\u4f9d\u8d56<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;npm install axios --save-dev<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u5b89\u88c5AntdUI\u5e93<\/h3>\n\n\n\n<p>AntdUI\u662f\u963f\u91cc\u9488\u5bf9React\u8bbe\u8ba1\u7684\u4e00\u4e2aUI\u5e93\uff0c\u5f00\u7bb1\u5373\u7528\uff0c\u6709\u4e30\u5bcc\u7684\u6587\u6863\u3002(\u800c\u4e14\u8fd8\u80fd\u6539\u989c\u8272)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">6.1 \u5b89\u88c5\u4f9d\u8d56<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">&nbsp;npm install redux --save-dev<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">6.2 \u5f15\u5165\u73af\u5883<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>\u5728<code>main.css<\/code>\u4e2d\u6dfb\u52a0<code>import 'antd\/dist\/antd.css'<\/code>\u5bfc\u5165CSS\u5e93<\/li><li>\u5728<code>Main.jsx<\/code>\u7684\u4ee3\u7801\u5934\u90e8\u6dfb\u52a0<code>import {\u7ec4\u4ef6\u540d\u79f0} from antd<\/code>\u5bfc\u5165\u7ec4\u4ef6<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u7ed3\u5c3e<\/h2>\n\n\n\n<p>\u8fd9\u7bc7\u6587\u7ae0\u5c31\u6b64\u544a\u4e00\u6bb5\u843d\u3002Axios\u548cESlint\u7684\u4f7f\u7528\u6211\u8fd8\u5728\u6478\u7d22\u4e2d\uff0c\u540e\u9762\u8fd8\u4f1a\u7ee7\u7eed\u66f4\u65b0\uff0c\u656c\u8bf7\u671f\u5f85\u3002\u76ee\u524d\u5728\u4f7f\u7528\u8fd9\u4e2a\u811a\u624b\u67b6\u91cd\u5199GuBlog\u65e5\u5fd7\u7a0b\u5e8f\u5f53\u4e2d\uff0c\u540e\u9762\u65f6\u673a\u6210\u719f\u540e\u4e5f\u4f1a\u540c\u65b0\u7248\u672c\u7684\u811a\u624b\u67b6\u6587\u7ae0\u4e00\u540c\u63a8\u51fa\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f \u6700\u8fd1\u5f00\u59cb\u636f\u996cReact\uff0c\u60f3\u7740\u5b66\u4f1a\u4e86React\u5c31\u80fd\u628aReact Native\u7ed9\u5b66\u4e60\u4e86\uff0c\u7136\u540e\u5c31\u80fd\u5199App\u3002\u4e3a &hellip; <a href=\"https:\/\/7gugu.com\/index.php\/2021\/06\/30\/react%e8%84%9a%e6%89%8b%e6%9e%b6v1-0\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cReact\u811a\u624b\u67b6V1.0\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,13],"tags":[],"class_list":["post-1473","post","type-post","status-publish","format-standard","hentry","category-29","category-13"],"_links":{"self":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts\/1473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1473"}],"version-history":[{"count":0,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/posts\/1473\/revisions"}],"wp:attachment":[{"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/7gugu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}