{"id":13387,"date":"2025-04-18T20:22:59","date_gmt":"2025-04-18T12:22:59","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/13387.html"},"modified":"2025-04-18T20:22:59","modified_gmt":"2025-04-18T12:22:59","slug":"react%e5%ad%a6%e4%b9%a0day02%ef%bc%88%e6%81%a8%e8%bf%9e%e6%8e%a5%e4%b8%8d%e4%b8%8a%e6%9c%8d%e5%8a%a1%e5%99%a8%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/13387.html","title":{"rendered":"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09"},"content":{"rendered":"<h4>\u53d7\u63a7\u8868\u5355\u7ed1\u5b9a<\/h4>\n<p>\u6982\u5ff5&#xff1a;\u4f7f\u7528React\u7ec4\u4ef6\u7684\u72b6\u6001&#xff08;useState&#xff09;\u63a7\u5236\u8868\u5355\u7684\u72b6\u6001<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"113\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244211fcaa.png\" width=\"589\" \/><\/p>\n<p>1. \u51c6\u5907\u4e00\u4e2aReact\u72b6\u6001\u503c<\/p>\n<p>const [value,setValue] &#061; useState(&#039;&#039;) <\/p>\n<p>2. \u901a\u8fc7value\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001&#xff0c;\u901a\u8fc7onChange\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\u540c\u6b65\u7684\u51fd\u6570<\/p>\n<p>&lt;input<br \/>\ntype&#061;&#034;text&#034;<br \/>\nvalue&#061;{value}<br \/>\nonChange&#061;{(e) &#061;&gt; setValue(e.target.value)}<br \/>\n\/&gt; <\/p>\n<h4 style=\"background-color:transparent\">React\u4e2d\u83b7\u53d6DOM<\/h4>\n<p>\u5728 React \u7ec4\u4ef6\u4e2d\u83b7\u53d6\/\u64cd\u4f5c DOM&#xff0c;\u9700\u8981\u4f7f\u7528 useRef React Hook\u94a9\u5b50\u51fd\u6570&#xff0c;\u5206\u4e3a\u4e24\u6b65:<\/p>\n<p>1. \u4f7f\u7528useRef\u521b\u5efa ref \u5bf9\u8c61&#xff0c;\u5e76\u4e0e JSX \u7ed1\u5b9a<\/p>\n<p>const inputRef &#061; useRef(null)<br \/>\n&lt;input type&#061;&#034;text&#034; ref&#061;{inputRef} \/&gt; <\/p>\n<p>2. \u5728DOM\u53ef\u7528\u65f6&#xff0c;\u901a\u8fc7 inputRef.current \u62ff\u5230 DOM \u5bf9\u8c61<\/p>\n<p>\u516b\u8001\u5e08\u8bf4\u8d3a\u8d8a\u8bf4\u8981\u5148\u770b\u5343\u950b\u634f<\/p>\n<p>\u6240\u4ee5\u8f6c\u6218 \u4e86<\/p>\n<p>\u611f\u89c9\u81ea\u5df1\u6709\u70b9\u7406\u89e3\u4e86react\u57fa\u672c\u4f7f\u7528&#xff1f;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"381\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-6802442134b72.png\" width=\"615\" \/><\/p>\n<p>\u00a0\u8fd9\u4ed6\u55b5\u4e0d\u662f\u548c\u9ed1\u9a6c\u662f\u4e24\u4e2a\u4e1c\u897f\u5417<\/p>\n<p>\u5f53\u65f6\u8c46\u5305\u5efa\u8bae\u6211\u4e0b\u7684<\/p>\n<p>\u8fd9\u4e2a\u811a\u624b\u67b6\u9700\u8981\u8f83\u9ad8\u7248\u672c\u7684Node.js&#xff08;14.18&#043;,16&#043;&#xff09;<\/p>\n<p>\u7136\u540e\u53ef\u4ee5<\/p>\n<p>npm create vite&#064;latest <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"84\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244214d101.png\" width=\"662\" \/><\/p>\n<p>\u5728\u5b89\u88c5\u7684\u65f6\u5019\u53ef\u4ee5\u9009JS\u6216\u8005JS&#043;SWC<\/p>\n<p>\u6240\u4ee5\u6211\u4eec\u9009\u62e9JS&#043;SWC<\/p>\n<p>\u00a0\u5728\u6587\u4ef6\u4e0a\u9762vite.svg\u662f\u6ca1\u6709\u88ab\u7f16\u8bd1\u8fc7\u7684<\/p>\n<p>\u4f7f\u7528npm run build\u5c31\u662f\u628a\u5b83\u7ed9\u6253\u5305<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"148\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244216f756.png\" width=\"352\" \/><\/p>\n<p>\u9006\u5929\u8ffd\u8e2a<\/p>\n<p>\u5df2\u7ecf\u53d6\u6d88\u4e86<\/p>\n<p>\u53ea\u80fd\u8bf4\u6211\u7684\u670d\u52a1\u5668\u6302\u4e86\u548c\u6211\u4e5f\u8131\u4e0d\u5f00\u5173\u7cfb<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"268\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244217d4e7.png\" width=\"492\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"259\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-6802442190b99.png\" width=\"443\" \/><\/p>\n<h4>ESLint\u914d\u7f6e\u4e0ePrettier\u914d\u7f6e<\/h4>\n<p>ESLint\u662f\u4ee3\u7801\u89c4\u8303\u63d2\u4ef6<\/p>\n<p>npm run lint<br \/>\nvite-plugin-eslint <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"76\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-68024421a4a25.png\" width=\"428\" \/><\/p>\n<p>Prettier\u662f\u4ee3\u7801\u683c\u5f0f\u5316\u63d2\u4ef6<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"321\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-68024421b2bc0.png\" width=\"631\" \/><\/p>\n<p>\u4e0b\u8f7d\u4e00\u4e2a\u8fd9\u4e2a\u4e1c\u897f<\/p>\n<p>\u00a0\u7136\u540e\u8fd8\u662f\u6309Alt&#043;Shift&#043;F\u5c31\u683c\u5f0f\u5316\u4e86<\/p>\n<h4>React\u6a21\u5757\u4e0ereact-dom\u6a21\u5757\u5206\u522b\u8d77\u4ec0\u4e48\u4f5c\u7528<\/h4>\n<p>react\u6a21\u5757\u6709\u6838\u5fc3\u529f\u80fd\u548c\u7ec4\u4ef6<\/p>\n<p>react-dom\u6a21\u5757\u662f\u64cd\u4f5c\u6d4f\u89c8\u5668DOM&#xff0c;react-dom\/server<\/p>\n<h4>JSX\u4e0eHTML\u4e4b\u95f4\u5199\u6cd5\u7684\u533a\u522b<\/h4>\n<p>\u9996\u5148\u662f\u6807\u7b7e\u8981\u5c0f\u5199\u3001\u5fc5\u987b\u95ed\u5408<\/p>\n<p>\u7136\u540e\u662f\u7c7b\u9009\u62e9\u5668\u8981\u5199\u6210className<\/p>\n<p>for\u5c5e\u6027\u8981\u6362\u6210htmlFor<\/p>\n<p>&lt;label htmlFor&#061;&#034;elem&#034;&gt;\u7528\u6237\u540d&lt;\/label&gt; <\/p>\n<p>\u5c5e\u6027\u662f\u91c7\u53d6\u9a7c\u5cf0\u547d\u540d\u6cd5<\/p>\n<p>\u5927\u62ec\u53f7\u4f7f\u7528JS<\/p>\n<p>\u4f46\u662f\u5bf9\u8c61\u548c\u51fd\u6570\u4e0d\u80fd\u76f4\u63a5\u653e\u5230JSX\u7684{}\u4e2d<\/p>\n<p>\u5c5e\u6027\u53ef\u4ee5\u4f7f\u7528 \u5927\u62ec\u53f7\u6e32\u67d3<\/p>\n<p>\u53ea\u6709\u552f\u4e00\u7684\u6839\u5143\u7d20<\/p>\n<p>import { Fragment } from &#039;react&#039; <\/p>\n<p>\u8fd9\u4e2a\u76f8\u5f53\u4e8e\u4e00\u4e2a\u5bb9\u5668&#xff0c;\u7b80\u5199\u5c31\u662f\u7a7a\u7bad\u5934<\/p>\n<p>&lt;&gt;&lt;\/&gt; <\/p>\n<p>\u533a\u522b\u662fFragment\u53ef\u4ee5\u6dfb\u52a0key\u5c5e\u6027<\/p>\n<h4>\u884c\u95f4\u6837\u5f0f\u3001\u5168\u5c40\u6837\u5f0f\u3001\u5c40\u90e8\u6837\u5f0f\u7684\u4f7f\u7528<\/h4>\n<p>function App(){<br \/>\n    return(<br \/>\n        &lt;div style&#061;{{width:&#039;100px&#039;,height:&#039;100px&#039;,background:&#039;red&#039;}}&gt;hello&lt;\/div&gt;<br \/>\n    )<br \/>\n}<\/p>\n<p>export default App <\/p>\n<p>\u5199\u7684\u4e1c\u897f\u6700\u540e\u4f1a\u901a\u8fc7\u811a\u624b\u67b6\u7f16\u8bd1\u6210\u65b0\u7684\u4e1c\u897f<\/p>\n<p>\u5f15\u7528\u7684\u8bdd\u9700\u8981\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p>&lt;div className&#061;{style.box2}&gt;aaa&lt;\/div&gt;<br \/>\n&lt;div className&#061;{style[&#039;head-title&#039;]}&gt;bbbbb&lt;\/div&gt; <\/p>\n<p>\u5f53\u628a\u914d\u7f6e\u6539\u4e00\u4e0b\u4e4b\u540e\u5c31\u597d\u7528\u4e86&#xff0c;\u8fd9\u662fvite.config.js&#xff1a;<\/p>\n<p>import { defineConfig } from &#039;vite&#039;<br \/>\nimport react from &#039;&#064;vitejs\/plugin-react-swc&#039;<br \/>\nimport eslintPlugin from &#039;vite-plugin-eslint&#039;<\/p>\n<p>\/\/ https:\/\/vite.dev\/config\/<br \/>\nexport default defineConfig({<br \/>\n  plugins: [<br \/>\n    react(),<br \/>\n    eslintPlugin({<br \/>\n      include: [&#039;src\/*.jsx&#039;, &#039;src\/**\/*.jsx&#039;],<br \/>\n    }),<br \/>\n  ],<br \/>\n  css:{<br \/>\n    modules:{<br \/>\n      localsConvention:&#039;camelCase&#039;<br \/>\n    }<br \/>\n  }<br \/>\n}) <\/p>\n<p>\u628a\u5b83\u53d8\u6210\u8fd9\u6837\u52a0\u4e00\u4e2acss\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u9a7c\u5cf0\u547d\u540d\u4f7f\u7528\u5f15\u5165\u7684\u6837\u5f0f\u4e86<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"454\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-68024421d8da0.png\" width=\"568\" \/><\/p>\n<h4>\u652f\u6301sass\u9884\u5904\u7406\u548cclassnames\u6a21\u5757\u7684\u4f7f\u7528<\/h4>\n<p>\u600e\u4e48\u652f\u6301\u9884\u5904\u7406\u5462&#xff1f;<\/p>\n<p>\u6267\u884c\u4e00\u4e0b\u8fd9\u4e2a\u547d\u4ee4&#xff1a;<\/p>\n<p>npm install sass <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"99\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-68024421efad8.png\" width=\"441\" \/><\/p>\n<p>\u6bcf\u4e00\u6b21\u7684\u65cb\u8f6c\u90fd\u662f\u5bf9\u6211\u5c0f\u5fc3\u810f\u7684\u953b\u70bc<\/p>\n<p>\u5c31\u6015\u53c8\u65ad\u8054\u4e86<\/p>\n<p>sass.scss<\/p>\n<p>$bg:red;<\/p>\n<p>.box3{<br \/>\n    background-color: $bg;<br \/>\n} <\/p>\n<p>classname\u6a21\u5757\u53c8\u662f\u5728\u5e72\u561b\u7684\u5462&#xff1f;<\/p>\n<p>\u7ee7\u7eed\u6dfb\u52a0\u4e00\u4e2a\u5305&#xff1a;<\/p>\n<p>npm install classnames <\/p>\n<p>import classNames from &#039;classnames&#039;<\/p>\n<p>function App(){<br \/>\n    const myClass &#061; classNames({<br \/>\n        box1:true,<br \/>\n        box2:false,<br \/>\n    })<br \/>\n    return(<br \/>\n        \/\/ &lt;div className&#061;{ myClass.join(&#039; &#039;)}&gt;<br \/>\n        \/\/     Hello App<br \/>\n        \/\/ &lt;\/div&gt;<br \/>\n        &lt;&gt;<br \/>\n            &lt;div className&#061;{myClass}&gt;<br \/>\n                hello App<br \/>\n            &lt;\/div&gt;<br \/>\n        &lt;\/&gt;<br \/>\n    )<br \/>\n}<\/p>\n<p>export default App <\/p>\n<p>\u8fd8\u53ef\u4ee5\u7528\u5176\u4ed6\u7684&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"82\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122258-6802442209d5a.png\" width=\"278\" \/><\/p>\n<h4>React\u5143\u7d20\u662f\u5982\u4f55\u6dfb\u52a0\u4e8b\u4ef6\u64cd\u4f5c<\/h4>\n<p>event\u5408\u6210\u4e8b\u4ef6&#xff0c;\u53ef\u4ee5\u89e3\u51b3\u4e00\u4e9b\u4e8b\u4ef6\u7684\u5904\u7406<\/p>\n<p>\u4e8b\u4ef6\u59d4\u6258\u5230\u5bb9\u5668\u5143\u7d20<\/p>\n<h4>\u5982\u4f55\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u8fdb\u884c\u4e0d\u540c\u7684\u5185\u5bb9\u6e32\u67d3<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"363\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122258-6802442216ec9.png\" width=\"664\" \/><\/p>\n<p>function App(){<br \/>\n    let count &#061; 0<br \/>\n    return (<br \/>\n        &lt;div&gt;<br \/>\n            Hello App<br \/>\n            &lt;br \/&gt;<br \/>\n            {count &gt;3 ? &lt;div&gt;hello react&lt;\/div&gt; :  &lt;p&gt;hi JavaScript&lt;\/p&gt;}<br \/>\n        &lt;\/div&gt;<br \/>\n    )<br \/>\n}<br \/>\nexport default App <\/p>\n<p>\u522b\u7684\u7c7b\u578b&#043;\u7a7a\u5b57\u7b26\u4e32\u662f\u8f6c\u6362\u6210\u5b57\u7b26\u4e32\u7c7b\u578b<\/p>\n<p>\u4f46\u662f\u5bf9\u8c61\u52a0\u4e0a\u7a7a\u5b57\u7b26\u4e32\u8f6c\u6210\u7684\u662f\u4e0d\u540c\u7684\u683c\u5f0f<\/p>\n<h4>\u5bf9\u4e00\u4e2a\u6570\u636e\u96c6\u5408\u8fdb\u884c\u6279\u91cf\u6e32\u67d3<\/h4>\n<p>\u5faa\u73af\u8bed\u53e5&#xff1a;for&#xff0c;while<\/p>\n<p>JSX\u4e2d\u9ed8\u8ba4\u5bf9\u6570\u7ec4\u8fdb\u884cjoin()\u64cd\u4f5c<\/p>\n<p>\u6570\u7ec4\u65b9\u6cd5:map<\/p>\n<p>\u5217\u8868\u6e32\u67d3\u9700\u8981\u6dfb\u52a0key\u5c5e\u6027\u3002\u8fd9\u4e9bkey\u4f1a\u544a\u8bc9react&#xff0c;\u6bcf\u4e2a\u7ec4\u4ef6\u91cc\u9762\u5bf9\u5e94\u7740\u6570\u7ec4\u7684\u54ea\u4e00\u9879&#xff0c;\u53ef\u4ee5\u5e2e\u52a9React\u63a8\u65ad\u53d1\u751f\u4e86\u4ec0\u4e48&#xff0c;\u4ece\u800c\u5f97\u4ee5\u6b63\u786e\u5730\u66f4\u65b0DOM\u6811<\/p>\n<p>\/\/ function App(){<br \/>\n\/\/     const list &#061; [&#039;aaaa&#039;,&#039;bbbb&#039;,&#039;cccc&#039;]<br \/>\n\/\/     for(let i&#061;0;i&lt;list.length;i&#043;&#043;)<br \/>\n\/\/     {<br \/>\n\/\/         list[i] &#061; &lt;li&gt;{list[i]}&lt;\/li&gt;<br \/>\n\/\/     }<br \/>\n\/\/     return (<br \/>\n\/\/         &lt;div&gt;hello App<br \/>\n\/\/             hello App<br \/>\n\/\/             &lt;br \/&gt;<br \/>\n\/\/             &lt;ul&gt;<br \/>\n\/\/                 {list}<br \/>\n\/\/             &lt;\/ul&gt;<br \/>\n\/\/         &lt;\/div&gt;<br \/>\n\/\/     )<br \/>\n\/\/ }<\/p>\n<p>\/\/ export default App<\/p>\n<p>function App(){<br \/>\n    const list &#061; [&#039;aaaa&#039;,&#039;bbbb&#039;,&#039;cccc&#039;]<br \/>\n    \/\/ for(let i&#061;0;i&lt;list.length;i&#043;&#043;)<br \/>\n    \/\/ {<br \/>\n    \/\/     list[i] &#061; &lt;li&gt;{list[i]}&lt;\/li&gt;<br \/>\n    \/\/ }<br \/>\n    return (<br \/>\n        &lt;div&gt;<br \/>\n            hello App<br \/>\n            &lt;br \/&gt;<br \/>\n            &lt;ul&gt;<br \/>\n                { list.map((item,index)&#061;&gt;&lt;li key&#061;{index}&gt;{item}&lt;\/li&gt;) }<br \/>\n            &lt;\/ul&gt;<br \/>\n        &lt;\/div&gt;<br \/>\n    )<br \/>\n}<\/p>\n<p>export default App <\/p>\n<h4>\u4e24\u79cd\u5b9e\u73b0\u7ec4\u4ef6\u7684\u6807\u8bb0\u5199\u6cd5<\/h4>\n<p>const Qf &#061; {<br \/>\n  Welcome() {<br \/>\n    return &lt;div&gt;hello Welcome&lt;\/div&gt;<br \/>\n  },<br \/>\n}<\/p>\n<p>const { Welcome } &#061; Qf<\/p>\n<p>function App() {<br \/>\n  return (<br \/>\n    &lt;div&gt;<br \/>\n      hello App<br \/>\n      &lt;Qf.Welcome&gt;&lt;\/Qf.Welcome&gt;<br \/>\n      &lt;Welcome&gt;&lt;\/Welcome&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>export default App<\/p>\n<p>\u8fd8\u6709\u4e00\u79cd\u51fd\u6570\u7684\u5199\u6cd5<\/p>\n<p>react\/display-name\u00a0\u89c4\u5219\u8981\u6c42\u6bcf\u4e2a React \u7ec4\u4ef6\u90fd\u5e94\u8be5\u6709\u4e00\u4e2a\u663e\u793a\u540d\u79f0&#xff0c;\u5728\u5f00\u53d1\u8005\u5de5\u5177\u548c\u9519\u8bef\u4fe1\u606f\u91cc&#xff0c;\u663e\u793a\u540d\u79f0\u6709\u52a9\u4e8e\u8bc6\u522b\u7ec4\u4ef6\u3002\u5bf9\u4e8e\u51fd\u6570\u5f0f\u7ec4\u4ef6&#xff0c;\u901a\u5e38\u51fd\u6570\u540d\u4f1a\u88ab\u5f53\u4f5c\u663e\u793a\u540d\u79f0&#xff0c;\u4f46\u5bf9\u4e8e\u50cf\u00a0Qf.Welcome\u00a0\u8fd9\u6837\u7684\u5d4c\u5957\u7ec4\u4ef6&#xff0c;ESLint \u53ef\u80fd\u65e0\u6cd5\u81ea\u52a8\u8bc6\u522b\u663e\u793a\u540d\u79f0\u3002<\/p>\n<p>\u6240\u4ee5\u9700\u8981\u624b\u52a8\u8bbe\u7f6e&#xff08;\u6211\u770b\u5343\u5cf0\u7684\u4e0a\u9762\u6ca1\u6709\u8981\u6c42\u8fd9\u4e2a&#xff0c;\u53ef\u80fd\u662f\u6211\u7528\u7684\u8fd9\u4e2a\u7248\u672c\u9ad8&#xff09;<\/p>\n<p>const Qf&#061;()&#061;&gt;{<br \/>\n    return (<br \/>\n        &lt;div&gt;<br \/>\n            hello Qf<br \/>\n        &lt;\/div&gt;<br \/>\n    )<br \/>\n}<\/p>\n<p>\/\/ \u624b\u52a8\u8bbe\u7f6e Qf \u7ec4\u4ef6\u7684\u663e\u793a\u540d\u79f0<br \/>\nQf.displayName &#061; &#039;Qf&#039;;<\/p>\n<p>Qf.Welcome&#061;()&#061;&gt;{<br \/>\n    return (&lt;div&gt;hello Welcome&lt;\/div&gt;)<br \/>\n}<\/p>\n<p>\/\/ \u624b\u52a8\u8bbe\u7f6e Qf.Welcome \u7ec4\u4ef6\u7684\u663e\u793a\u540d\u79f0<br \/>\nQf.Welcome.displayName &#061; &#039;Qf.Welcome&#039;;<\/p>\n<p>function App() {<br \/>\n  return (<br \/>\n    &lt;div&gt;<br \/>\n      hello App<br \/>\n      &lt;Qf\/&gt;<br \/>\n      &lt;Qf.Welcome&gt;&lt;\/Qf.Welcome&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  )<br \/>\n}<\/p>\n<p>export default App<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb854\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf24\u6b21\u30022. \u5728DOM\u53ef\u7528\u65f6\uff0c\u901a\u8fc7 inputRef.current \u62ff\u5230 DOM \u5bf9\u8c61\u30022. \u901a\u8fc7value\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\uff0c\u901a\u8fc7onChange\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\u540c\u6b65\u7684\u51fd\u6570\u3002\u6982\u5ff5\uff1a\u4f7f\u7528React\u7ec4\u4ef6\u7684\u72b6\u6001\uff08useState\uff09\u63a7\u5236\u8868\u5355\u7684\u72b6\u6001\u3002\u8fd9\u4e2a\u811a\u624b\u67b6\u9700\u8981\u8f83\u9ad8\u7248\u672c\u7684Node.js\uff0814.18+,16+\uff091. \u4f7f\u7528useRef\u521b\u5efa ref \u5bf9\u8c61\uff0c\u5e76\u4e0e JSX \u7ed1\u5b9a\u3002\u5728\u6587\u4ef6\u4e0a\u9762vite.svg\u662f\u6ca1\u6709\u88ab\u7f16\u8bd1\u8fc7\u7684\u3002\u611f\u89c9\u81ea\u5df1\u6709\u70b9\u7406\u89e3\u4e86react\u57fa\u672c\u4f7f\u7528\uff1f\u5728\u5b89\u88c5\u7684\u65f6\u5019\u53ef\u4ee5\u9009JS\u6216\u8005JS+SWC\u3002\u53ea\u80fd\u8bf4\u6211\u7684\u670d\u52a1\u5668\u6302\u4e86\u548c\u6211\u4e5f\u8131\u4e0d\u5f00\u5173\u7cfb\u3002<\/p>\n","protected":false},"author":2,"featured_media":13375,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[723,524,371,43],"topic":[],"class_list":["post-13387","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-react","tag-react-js","tag-371","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/13387.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb854\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf24\u6b21\u30022. \u5728DOM\u53ef\u7528\u65f6\uff0c\u901a\u8fc7 inputRef.current \u62ff\u5230 DOM \u5bf9\u8c61\u30022. \u901a\u8fc7value\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\uff0c\u901a\u8fc7onChange\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\u540c\u6b65\u7684\u51fd\u6570\u3002\u6982\u5ff5\uff1a\u4f7f\u7528React\u7ec4\u4ef6\u7684\u72b6\u6001\uff08useState\uff09\u63a7\u5236\u8868\u5355\u7684\u72b6\u6001\u3002\u8fd9\u4e2a\u811a\u624b\u67b6\u9700\u8981\u8f83\u9ad8\u7248\u672c\u7684Node.js\uff0814.18+,16+\uff091. \u4f7f\u7528useRef\u521b\u5efa ref \u5bf9\u8c61\uff0c\u5e76\u4e0e JSX \u7ed1\u5b9a\u3002\u5728\u6587\u4ef6\u4e0a\u9762vite.svg\u662f\u6ca1\u6709\u88ab\u7f16\u8bd1\u8fc7\u7684\u3002\u611f\u89c9\u81ea\u5df1\u6709\u70b9\u7406\u89e3\u4e86react\u57fa\u672c\u4f7f\u7528\uff1f\u5728\u5b89\u88c5\u7684\u65f6\u5019\u53ef\u4ee5\u9009JS\u6216\u8005JS+SWC\u3002\u53ea\u80fd\u8bf4\u6211\u7684\u670d\u52a1\u5668\u6302\u4e86\u548c\u6211\u4e5f\u8131\u4e0d\u5f00\u5173\u7cfb\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/13387.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T12:22:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244211fcaa.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/13387.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/13387.html\",\"name\":\"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T12:22:59+00:00\",\"dateModified\":\"2025-04-18T12:22:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/13387.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/13387.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/13387.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/13387.html","og_locale":"zh_CN","og_type":"article","og_title":"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb854\u6b21\uff0c\u70b9\u8d5e29\u6b21\uff0c\u6536\u85cf24\u6b21\u30022. \u5728DOM\u53ef\u7528\u65f6\uff0c\u901a\u8fc7 inputRef.current \u62ff\u5230 DOM \u5bf9\u8c61\u30022. \u901a\u8fc7value\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\uff0c\u901a\u8fc7onChange\u5c5e\u6027\u7ed1\u5b9a\u72b6\u6001\u540c\u6b65\u7684\u51fd\u6570\u3002\u6982\u5ff5\uff1a\u4f7f\u7528React\u7ec4\u4ef6\u7684\u72b6\u6001\uff08useState\uff09\u63a7\u5236\u8868\u5355\u7684\u72b6\u6001\u3002\u8fd9\u4e2a\u811a\u624b\u67b6\u9700\u8981\u8f83\u9ad8\u7248\u672c\u7684Node.js\uff0814.18+,16+\uff091. \u4f7f\u7528useRef\u521b\u5efa ref \u5bf9\u8c61\uff0c\u5e76\u4e0e JSX \u7ed1\u5b9a\u3002\u5728\u6587\u4ef6\u4e0a\u9762vite.svg\u662f\u6ca1\u6709\u88ab\u7f16\u8bd1\u8fc7\u7684\u3002\u611f\u89c9\u81ea\u5df1\u6709\u70b9\u7406\u89e3\u4e86react\u57fa\u672c\u4f7f\u7528\uff1f\u5728\u5b89\u88c5\u7684\u65f6\u5019\u53ef\u4ee5\u9009JS\u6216\u8005JS+SWC\u3002\u53ea\u80fd\u8bf4\u6211\u7684\u670d\u52a1\u5668\u6302\u4e86\u548c\u6211\u4e5f\u8131\u4e0d\u5f00\u5173\u7cfb\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/13387.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T12:22:59+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418122257-680244211fcaa.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/13387.html","url":"https:\/\/www.wsisp.com\/helps\/13387.html","name":"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T12:22:59+00:00","dateModified":"2025-04-18T12:22:59+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/13387.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/13387.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/13387.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"REACT\u5b66\u4e60DAY02\uff08\u6068\u8fde\u63a5\u4e0d\u4e0a\u670d\u52a1\u5668\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/13387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=13387"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/13387\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/13375"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=13387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=13387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=13387"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=13387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}