{"id":42414,"date":"2025-06-08T15:27:49","date_gmt":"2025-06-08T07:27:49","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/42414.html"},"modified":"2025-06-08T15:27:49","modified_gmt":"2025-06-08T07:27:49","slug":"%e3%80%90react%e3%80%91jsx-%e4%bb%8e%e5%a3%b0%e6%98%8e%e5%bc%8f%e8%af%ad%e6%b3%95%e5%8f%98%e6%88%90%e5%91%bd%e4%bb%a4%e5%bc%8f%e8%af%ad%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/42414.html","title":{"rendered":"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5"},"content":{"rendered":"<p>\u5728 React \u4e2d&#xff0c;JSX \u662f\u4e00\u79cd\u58f0\u660e\u5f0f\u7684\u8bed\u6cd5\u6269\u5c55&#xff0c;\u5b83\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u4ee5\u7c7b\u4f3c HTML \u7684\u65b9\u5f0f\u63cf\u8ff0\u7528\u6237\u754c\u9762\u3002<\/p>\n<p>\u7136\u800c&#xff0c;\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b&#xff0c;\u53ef\u80fd\u5e0c\u671b\u5c06 JSX \u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5&#xff0c;\u4ee5\u83b7\u5f97\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u6216\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002(ckeditor.com)<\/p>\n<hr \/>\n<h4>JSX \u5230\u547d\u4ee4\u5f0f\u8bed\u6cd5\u7684\u8f6c\u6362<\/h4>\n<p>JSX \u8bed\u6cd5\u5728\u7f16\u8bd1\u65f6\u4f1a\u88ab\u8f6c\u6362\u4e3a React.createElement \u6216\u5176\u4ed6\u76f8\u5173\u51fd\u6570\u7684\u8c03\u7528\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u901a\u5e38\u7531 Babel \u7b49\u5de5\u5177\u81ea\u52a8\u5b8c\u6210\u3002\u4f8b\u5982&#xff0c;\u4ee5\u4e0b JSX \u4ee3\u7801&#xff1a;(legacy.reactjs.org, Reddit)<\/p>\n<p>const element &#061; &lt;h1&gt;Hello, world!&lt;\/h1&gt;;<\/p>\n<p>\u5728\u7f16\u8bd1\u540e\u4f1a\u88ab\u8f6c\u6362\u4e3a&#xff1a;<\/p>\n<p><span class=\"token keyword\">const<\/span> element <span class=\"token operator\">&#061;<\/span> React<span class=\"token punctuation\">.<\/span><span class=\"token function\">createElement<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;h1&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;Hello, world!&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5728 React 17 \u5f15\u5165\u7684\u65b0 JSX \u8f6c\u6362\u4e2d&#xff0c;\u7f16\u8bd1\u5668\u4f1a\u81ea\u52a8\u5f15\u5165 jsx \u51fd\u6570&#xff0c;\u800c\u4e0d\u518d\u9700\u8981\u663e\u5f0f\u5bfc\u5165 React&#xff1a;(legacy.reactjs.org)<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">{<\/span> jsx <span class=\"token keyword\">as<\/span> _jsx <span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">from<\/span> <span class=\"token string\">&#039;react\/jsx-runtime&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> element <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">_jsx<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;h1&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token literal-property property\">children<\/span><span class=\"token operator\">:<\/span> <span class=\"token string\">&#039;Hello, world!&#039;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u79cd\u8f6c\u6362\u65b9\u5f0f\u4f7f\u5f97 JSX \u66f4\u52a0\u7075\u6d3b&#xff0c;\u5e76\u51cf\u5c11\u4e86\u5bf9 React \u7684\u76f4\u63a5\u4f9d\u8d56\u3002 <\/p>\n<hr \/>\n<h4>\u793a\u4f8b&#xff1a;\u4ece JSX \u5230\u547d\u4ee4\u5f0f\u8bed\u6cd5<\/h4>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5c06 JSX \u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5\u7684\u793a\u4f8b&#xff1a;<\/p>\n<p>\u4f7f\u7528 JSX&#xff1a;<\/p>\n<p>function Welcome(props) {<br \/>\n  return &lt;h1&gt;Hello, {props.name}&lt;\/h1&gt;;<br \/>\n}<\/p>\n<p>\u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5&#xff1a;<\/p>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function\">Welcome<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">props<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> React<span class=\"token punctuation\">.<\/span><span class=\"token function\">createElement<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;h1&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">&#096;<\/span><span class=\"token string\">Hello, <\/span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${<\/span>props<span class=\"token punctuation\">.<\/span>name<span class=\"token interpolation-punctuation punctuation\">}<\/span><\/span><span class=\"token template-punctuation string\">&#096;<\/span><\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\u3002\u5728 React \u4e2d\uff0cJSX \u662f\u4e00\u79cd\u58f0\u660e\u5f0f\u7684\u8bed\u6cd5\u6269\u5c55\uff0c\u5b83\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u4ee5\u7c7b\u4f3c HTML \u7684\u65b9\u5f0f\u63cf\u8ff0\u7528\u6237\u754c\u9762\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u5e0c\u671b\u5c06 JSX \u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5\uff0c\u4ee5\u83b7\u5f97\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u6216\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3943,524,87,885],"topic":[],"class_list":["post-42414","post","type-post","status-publish","format-standard","hentry","category-server","tag-react-","tag-react-js","tag-87","tag-885"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \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\/42414.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\u3002\u5728 React \u4e2d\uff0cJSX \u662f\u4e00\u79cd\u58f0\u660e\u5f0f\u7684\u8bed\u6cd5\u6269\u5c55\uff0c\u5b83\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u4ee5\u7c7b\u4f3c HTML \u7684\u65b9\u5f0f\u63cf\u8ff0\u7528\u6237\u754c\u9762\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u5e0c\u671b\u5c06 JSX \u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5\uff0c\u4ee5\u83b7\u5f97\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u6216\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/42414.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-08T07:27:49+00:00\" \/>\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=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42414.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/42414.html\",\"name\":\"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-08T07:27:49+00:00\",\"dateModified\":\"2025-06-08T07:27:49+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/42414.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/42414.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/42414.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5\"}]},{\"@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":"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \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\/42414.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\u3002\u5728 React \u4e2d\uff0cJSX \u662f\u4e00\u79cd\u58f0\u660e\u5f0f\u7684\u8bed\u6cd5\u6269\u5c55\uff0c\u5b83\u4f7f\u5f97\u5f00\u53d1\u8005\u80fd\u591f\u4ee5\u7c7b\u4f3c HTML \u7684\u65b9\u5f0f\u63cf\u8ff0\u7528\u6237\u754c\u9762\u3002\u7136\u800c\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u5e0c\u671b\u5c06 JSX \u8f6c\u6362\u4e3a\u547d\u4ee4\u5f0f\u8bed\u6cd5\uff0c\u4ee5\u83b7\u5f97\u66f4\u7cbe\u7ec6\u7684\u63a7\u5236\u6216\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/42414.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-08T07:27:49+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/42414.html","url":"https:\/\/www.wsisp.com\/helps\/42414.html","name":"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-08T07:27:49+00:00","dateModified":"2025-06-08T07:27:49+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/42414.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/42414.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/42414.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010React\u3011jsx \u4ece\u58f0\u660e\u5f0f\u8bed\u6cd5\u53d8\u6210\u547d\u4ee4\u5f0f\u8bed\u6cd5"}]},{"@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\/42414","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=42414"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/42414\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=42414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=42414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=42414"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=42414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}