{"id":38339,"date":"2023-10-19T03:15:13","date_gmt":"2022-11-07T02:57:12","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/"},"modified":"2024-05-04T04:57:08","modified_gmt":"2024-05-03T20:57:08","slug":"%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/","title":{"rendered":"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168"},"content":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u662f\u300eQiita\u516c\u53f8Advent Calendar 2022\u300f\u7684\u7b2c15\u5929\u7684\u6587\u7ae0\u3002<\/p>\n<p>\u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8eRails\u5e94\u7528\u7a0b\u5e8f\u7684React\u89c6\u56fe\u5e93\uff0cReact on Rails\u662f\u4e00\u4e2a\u65b9\u4fbf\u7684\u5e93\uff0c\u5e7f\u6cdb\u5e94\u7528\u4e8eQiita\u516c\u53f8\u7684\u4ea7\u54c1\u5f00\u53d1\u4e2d\u3002\u4f46\u662f\uff0c\u7531\u4e8e\u8de8\u8d8a\u591a\u79cd\u8bed\u8a00\u7684\u7279\u6027\uff0c\u4f7f\u7528React on Rails\u8fdb\u884c\u4ea4\u53c9\u8bed\u8a00\u7684\u64cd\u4f5c\u9a8c\u8bc1\u7b49\u5b58\u5728\u4e00\u4e9b\u56f0\u96be\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5728\u89c6\u56fe\u4e2d\u4f7f\u7528JSON Schema\u4e3a\u8de8\u8bed\u8a00\u4f20\u9012\u4fe1\u606f\u5e94\u7528\u6a21\u5f0f\u3002<\/p>\n<p>\u8fd9\u4e2a\u60f3\u6cd5\u5728Qiita\u516c\u53f8\u7684\u5404\u79cd\u4ea7\u54c1\u4e2d\u5b9e\u9645\u4f7f\u7528\uff0c\u5e76\u4ee5JsonSchemaView\u7684\u5f62\u5f0f\u4f5c\u4e3a\u5f00\u653e\u6e90\u4ee3\u7801\u53d1\u5e03\u3002\u5982\u679c\u60a8\u611f\u5174\u8da3\uff0c\u8bf7\u52a1\u5fc5\u53c2\u8003\u4e00\u4e0b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u5728Rails\u4e0a\u4f7f\u7528React\u7684\u597d\u5904\u548c\u6311\u6218\u3002<\/h2>\n<p>React on Rails \u662f\u4e00\u4e2a\u5e93\uff0c\u53ef\u4ee5\u8ba9\u60a8\u5728Rails\u89c6\u56fe\u4e2d\u4f7f\u7528React\u7ec4\u4ef6\u3002<br \/>\n\u4e00\u65e6\u8fdb\u884c\u8bbe\u7f6e\uff0c\u60a8\u5c31\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5728\u89c6\u56fe\u4e2d\u8f7b\u677e\u5730\u4f7f\u7528React\u7ec4\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;%=<\/span> <span class=\"n\">react_component<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"HelloComponent\"<\/span><span class=\"p\">,<\/span> <span class=\"ss\">props: <\/span><span class=\"p\">{<\/span> <span class=\"ss\">name: <\/span><span class=\"s2\">\"Taro\"<\/span> <span class=\"p\">})<\/span> <span class=\"cp\">%&gt;<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"kd\">const<\/span> <span class=\"nx\">HelloComponent<\/span> <span class=\"o\">=<\/span> <span class=\"p\">({<\/span> <span class=\"nx\">name<\/span> <span class=\"p\">}:<\/span> <span class=\"p\">{<\/span> <span class=\"nl\">name<\/span><span class=\"p\">:<\/span> <span class=\"kr\">string<\/span> <span class=\"p\">})<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\r\n  <span class=\"k\">return <\/span><span class=\"p\">(&lt;<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;<\/span>Hello, <span class=\"si\">{<\/span><span class=\"nx\">name<\/span><span class=\"si\">}<\/span>!<span class=\"p\">&lt;\/<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;)<\/span>\r\n<span class=\"p\">}<\/span>\r\n<span class=\"nx\">ReactOnRails<\/span><span class=\"p\">.<\/span><span class=\"nf\">register<\/span><span class=\"p\">({<\/span> <span class=\"nx\">HelloWorld<\/span> <span class=\"p\">})<\/span>\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u5e93\u975e\u5e38\u65b9\u4fbf\uff0c\u4f46\u7531\u4e8e\u6d89\u53ca\u591a\u79cd\u8bed\u8a00\uff0c\u6240\u4ee5\u5b58\u5728\u52a8\u4f5c\u9a8c\u8bc1\u7684\u56f0\u96be\u3002\u4eceRails\u7684\u89d2\u5ea6\u6765\u770b\uff0c\u7ec4\u4ef6\u540d\u79f0\u548c\u5c5e\u6027\u53ea\u662f\u5b57\u7b26\u4e32\u548c\u54c8\u5e0c\u5bf9\u8c61\uff0cRails\u672c\u8eab\u65e0\u6cd5\u9a8c\u8bc1\u5b83\u4eec\u7684\u6b63\u786e\u6027\u3002<\/p>\n<h3>\u5728Rails\u4e2d\uff0c\u4ec5\u901a\u8fc7\u7ec4\u4ef6\u540d\u79f0\u548c\u7ec4\u4ef6\u5c5e\u6027\u6765\u9a8c\u8bc1\u662f\u5426\u6b63\u786e\u6307\u5b9a\u662f\u56f0\u96be\u7684\u3002<\/h3>\n<p>\u4f7f\u7528React\u4f5c\u4e3a\u524d\u7aef\u6846\u67b6\uff0c\u914d\u5408Rails\u4f5c\u4e3a\u540e\u7aef\u6846\u67b6\u7684\u5f00\u53d1\u673a\u5236\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Rails \u5074<\/ul>\n<\/li>\n<\/ul>\n<p>react_component \u30e1\u30bd\u30c3\u30c9\u306b\u3088\u308a\u3001\u57cb\u3081\u8fbc\u3080\u4e88\u5b9a\u5730\u306b (\u5229\u7528\u3057\u305f\u3044 React Component \u540d, \u305d\u306e props) \u306e\u60c5\u5831\u3092\u542b\u3080 HTML \u30bf\u30b0\u3092 render \u3059\u308b<\/p>\n<p>JavaScript \u5074 (React \u5074)<\/p>\n<p>\u57cb\u3081\u8fbc\u3081\u308b\u3088\u3046\u306b\u3057\u305f\u3044 React Component \u3092\u4e88\u3081 ReactOnRails.register \u3067\u767b\u9332<br \/>\nReact on Rails \u306e JS \u5b9f\u88c5\u304c\u3001 react_component \u304c render \u3057\u305f HTML \u30bf\u30b0\u3092\u767a\u898b\u3057\u3001\u305d\u308c\u3092\u5bfe\u5fdc\u3057\u305f React Component \u306b\u7f6e\u304d\u63db\u3048<\/p>\n<p>\u73b0\u5728\u7684\u60c5\u51b5\u662f\u8fd9\u6837\u7684\u3002<\/p>\n<p>\u5982\u679c\u5c06\u5728\u8fd9\u91cc\u4ea4\u6d41\u7684\u4fe1\u606f\u8fdb\u884c\u8d85\u7b80\u5316\u5e76\u4ee5\u56fe\u5f62\u65b9\u5f0f\u5448\u73b0\uff0c\u60c5\u51b5\u5c06\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/14-0.png\" alt=\"react-on-rails-dataflow.drawio.png\" \/><\/div>\n<p>\u5728\u8fd9\u91cc\uff0c\u4eceRails\u7aef\u4f20\u9012\u5230JS\u7aef\u7684\u4fe1\u606f\u662f(\u6240\u9700\u4f7f\u7528\u7684React\u7ec4\u4ef6\u540d\u79f0\uff0c\u4ee5\u53ca\u8be5\u7ec4\u4ef6\u7684props)\u7684\u7ec4\u5408\u3002<br \/>\n\u7136\u800c\uff0cRails\u7aef\u5e76\u4e0d\u77e5\u9053JS\u7aef\u6709\u54ea\u4e9b\u7ec4\u4ef6\uff08\u662f\u5426\u5df2\u6ce8\u518c\uff09\u3002\u53ea\u6709\u5728JavaScript\u7aef\u5904\u7406\uff0c\u624d\u80fd\u786e\u8ba4\u6307\u5b9a\u7684React\u7ec4\u4ef6\u540d\u79f0\u548cprops\u662f\u5426\u6b63\u786e\u3002<\/p>\n<p>\u800c\u4e14\uff0c\u7ecf\u5e38\u4f1a\u51fa\u73b0React\u7ec4\u4ef6\u540d\u79f0\u548cprops\u4f20\u9012\u51fa\u73b0\u9519\u8bef\u7684\u60c5\u51b5\u3002\u5982\u7ec4\u4ef6\u540d\u79f0\u7684\u62fc\u5199\u9519\u8bef\uff0cReact\u7aef\u7684props\u53d8\u66f4\uff0c\u89c6\u56fe\u5e8f\u5217\u5316\u5904\u7406\u7684\u53d8\u66f4\u7b49\u7b49\uff0c\u65e0\u9650\u591a\u79cd\u60c5\u51b5\u53ef\u80fd\u4f1a\u53d1\u751f\u3002<\/p>\n<p>\u6709\u51e0\u79cd\u65b9\u6cd5\u53ef\u4ee5\u7528\u4e8e\u8fd9\u4e9b\u9a8c\u8bc1\uff0c\u4f8b\u5982\u91c7\u7528\u670d\u52a1\u5668\u7aef\u6e32\u67d3\uff08Server Side Rendering\uff09\u6216\u4f7f\u7528\u6d4f\u89c8\u5668\u6d4b\u8bd5\u5982\u7279\u6027\u89c4\u8303\uff08Feature Spec\uff09\u548c\u7cfb\u7edf\u89c4\u8303\uff08System Spec\uff09\u3002\u7136\u800c\uff0c\u4e00\u4e2a\u7f3a\u70b9\u662f\u5b9e\u65bd\u548c\u6d4b\u8bd5\u53ef\u80fd\u4f1a\u53d8\u5f97\u8fc7\u4e8e\u590d\u6742\u548c\u7e41\u7410\u3002<\/p>\n<h2>\u7ed9\u7ec4\u4ef6\u548c\u5176 props \u4f7f\u7528 JSON Schema \u63d0\u4f9b\u6a21\u5f0f<\/h2>\n<p>\u8fd9\u91cc\u7684\u95ee\u9898\u662f\uff0c\u5bf9\u4e8e\u5b9a\u4e49\u4e86\u4ec0\u4e48\u6837\u7684React\u7ec4\u4ef6\u4ee5\u53ca\u5bf9\u5b83\u7684props\u6709\u4f55\u671f\u671b\u503c\u7684\u4fe1\u606f\uff0c\u5b83\u90fd\u88abJavaScript\uff08TypeScript\uff09\u7aef\u6240\u5c01\u95ed\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u8003\u8651\u4f7f\u7528 JSON Schema \u6765\u5b9a\u4e49 Rails \u4f20\u9012\u7ed9 JavaScript \u7684\u4fe1\u606f\uff08\u5305\u62ecReact\u7ec4\u4ef6\u540d\u79f0\u548c\u5176\u5c5e\u6027\uff09\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u6839\u636e JSON Schema \u53ef\u4ee5\u751f\u6210\u7c7b\u578b\u5b9a\u4e49\u548c\u9a8c\u8bc1\u6570\u636e\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u4fe1\u606f\u4f20\u64ad\u4e2d\u8de8\u8bed\u8a00\u5931\u8d25\u7684\u53ef\u80fd\u6027\uff0c\u5e76\u80fd\u591f\u72ec\u7acb\u9a8c\u8bc1\u5404\u81ea\u804c\u8d23\u4e2d\u7684\u6b63\u786e\u6027\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/22-0.png\" alt=\"json_schema.drawio.png\" \/><\/div>\n<h3>\u203b \u4ec0\u4e48\u662fJSON Schema\uff1f<\/h3>\n<p>&nbsp;<\/p>\n<p>JSON Schema\u662f\u4e00\u79cd\u53ef\u4ee5\u5b9a\u4e49JSON\u683c\u5f0f\u6570\u636e\u6216\u6587\u6863\u7684\u6a21\u5f0f\uff08\u6570\u636e\u7ed3\u6784\uff09\u7684\u6a21\u5f0f\u63cf\u8ff0\u8bed\u8a00\u3002<\/p>\n<p>JSON Schema\u7684\u4f18\u52bf\u662f\u53ef\u4ee5\u5229\u7528\u5404\u79cd\u5b9e\u73b0\u65b9\u5f0f\u3002\u6211\u4eec\u53ef\u4ee5\u5229\u7528JSON Schema\u6765\u751f\u6210\u9a8c\u8bc1\u5668\u3001\u751f\u6210\u7c7b\u578b\u5b9a\u4e49\u3001\u751f\u6210React\u8868\u5355\u5b9a\u4e49\u3001\u751f\u6210\u6d4b\u8bd5\u5bf9\u8c61\uff0c\u4ee5\u53ca\u901a\u8fc7Language Server\u6765\u5b9e\u73b0JSON \/ YAML\u6587\u4ef6\u7684\u8865\u5168\u7b49\u7b49\u3002\u4e30\u5bcc\u7684\u5de5\u5177\u4f7f\u6211\u4eec\u80fd\u591f\u5728\u5404\u79cd\u573a\u666f\u4e0b\u7075\u6d3b\u8fd0\u7528JSON Schema\u3002\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0cOpenAPI\u4f5c\u4e3aREST API\u7684\u63cf\u8ff0\u683c\u5f0f\uff0c\u4e5f\u662f\u57fa\u4e8eJSON Schema\u8fdb\u884c\u6269\u5c55\u5b9a\u4e49\u7684\u3002<\/p>\n<p>\u5728Qiita\u4e0a\u4e5f\u4f7f\u7528\u4e86JSON Schema\uff0c\u5e76\u4e14\u63d0\u4f9b\u4e86Qiita API v2\u7684JSON Schema\uff08http:\/\/qiita.com\/api\/v2\/schema\uff09\uff0c\u57fa\u4e8e\u8fd9\u4e2a\u8fdb\u884c\u4e86API\u6587\u6863\u7684\u751f\u6210\u3002<\/p>\n<p>\u8fd9\u4e9b\u6280\u672f\u7ec6\u8282\u5df2\u7ecf\u5728\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e2d\u603b\u7ed3\u4e86\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u4e3a\u5728View\u4e2d\u4f20\u64ad\u7684\u4fe1\u606f\u63d0\u4f9b\u67b6\u6784\u7684\u662fJsonSchemaView\u3002<\/h3>\n<p>\u6240\u4ee5\uff0c\u4e3a\u4e86\u5b9e\u73b0\u4f7f\u7528JSON Schema\u5728\u89c6\u56fe\u4e4b\u95f4\u8fdb\u884c\u534f\u4f5c\uff0c\u6211\u4eec\u5f00\u53d1\u4e86\u4e00\u4e2a\u540d\u4e3aJsonSchemaView\u7684\u5f00\u6e90\u8f6f\u4ef6\u3002<\/p>\n<p>\u5728JsonSchemaView\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bRuby\u4ee3\u7801\u6765\u63cf\u8ff0Component\u53ca\u5176props\u7684JSON Schema\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"c1\"># \u30af\u30e9\u30b9\u540d\u306f Component \u540d\u3068\u540c\u3058\u306b\u306a\u308b\u3088\u3046\u306b\u3059\u308b<\/span>\r\n<span class=\"k\">class<\/span> <span class=\"nc\">HelloComponent<\/span> <span class=\"o\">&lt;<\/span> <span class=\"no\">JsonSchemaView<\/span><span class=\"o\">::<\/span><span class=\"no\">Component<\/span>\r\n  <span class=\"n\">renderer_class<\/span><span class=\"p\">(<\/span><span class=\"ss\">:react_on_rails<\/span><span class=\"p\">)<\/span>\r\n\r\n  <span class=\"n\">props_class<\/span> <span class=\"k\">do<\/span>\r\n    <span class=\"n\">property<\/span><span class=\"p\">(<\/span><span class=\"ss\">:name<\/span><span class=\"p\">,<\/span> <span class=\"ss\">type: <\/span><span class=\"no\">String<\/span><span class=\"p\">)<\/span>\r\n    <span class=\"nb\">attr_reader<\/span> <span class=\"ss\">:name<\/span>\r\n\r\n    <span class=\"k\">def<\/span> <span class=\"nf\">initialize<\/span><span class=\"p\">(<\/span><span class=\"nb\">name<\/span><span class=\"p\">:)<\/span>\r\n      <span class=\"vi\">@name<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">name<\/span>\r\n    <span class=\"k\">end<\/span>\r\n  <span class=\"k\">end<\/span>\r\n<span class=\"k\">end<\/span>\r\n<\/code><\/pre>\n<p>\u7528\u4e8e\u5b9a\u4e49 JSON Schema \u7684 DSL \u662f JSONWorld \u6216\u5176\u6269\u5c55\u3002\u5728\u7f16\u5199\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 JsonWorld \u4ece\u6a21\u578b\u751f\u6210 JSON Schema \u5e76\u4f5c\u4e3a\u53c2\u8003\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u5c06\u5b9a\u4e49\u7684\u7ec4\u4ef6\u4f20\u9012\u7ed9Rails\u7684render\u65b9\u6cd5\uff0c\u4ee5\u66ff\u4ee3\u4f7f\u7528react_component\u65b9\u6cd5\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"n\">render<\/span> <span class=\"no\">HelloComponent<\/span><span class=\"p\">.<\/span><span class=\"nf\">new<\/span><span class=\"p\">(<\/span><span class=\"ss\">props: <\/span><span class=\"p\">{<\/span> <span class=\"ss\">name: <\/span><span class=\"s2\">\"Taro\"<\/span> <span class=\"p\">})<\/span> <span class=\"c1\"># react_component(\"HelloComponent\", props: { name: \"Taro\" })<\/span>\r\n<\/code><\/pre>\n<p>\u5728\u8fdb\u884c\u6e32\u67d3\u65f6\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u9a8c\u8bc1\u5176\u662f\u5426\u7b26\u5408\u8be5\u6a21\u5f0f\uff0c\u5982\u679c\u4e0d\u7b26\u5408\uff0c\u5219\u4f1a\u629b\u51fa\u5f02\u5e38\u3002\u8fd9\u6837\uff0cRails \u5c31\u80fd\u591f\u9632\u6b62\u4f20\u64ad\u4e0e\u6a21\u5f0f\u4e0d\u5339\u914d\u7684\u6570\u636e\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"n\">render<\/span> <span class=\"no\">HelloComponent<\/span><span class=\"p\">.<\/span><span class=\"nf\">new<\/span><span class=\"p\">(<\/span><span class=\"ss\">props: <\/span><span class=\"p\">{<\/span> <span class=\"ss\">name: <\/span><span class=\"s2\">\"Taro\"<\/span> <span class=\"p\">})<\/span> <span class=\"c1\"># valid<\/span>\r\n<span class=\"n\">render<\/span> <span class=\"no\">HelloComponent<\/span><span class=\"p\">.<\/span><span class=\"nf\">new<\/span><span class=\"p\">(<\/span><span class=\"ss\">props: <\/span><span class=\"p\">{<\/span> <span class=\"ss\">naem: <\/span><span class=\"s2\">\"Taro\"<\/span> <span class=\"p\">})<\/span> <span class=\"c1\"># invalid \u306a\u306e\u3067\u3001 Rails \u5074\u306e render \u6642\u306b\u4f8b\u5916\u304c\u6295\u3052\u3089\u308c\u308b<\/span>\r\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 json-schema-to-typescript \u4ece\u8be5 JSON Schema \u4e2d\u751f\u6210 TypeScript \u7c7b\u578b\u3002\u901a\u8fc7\u4f7f\u7528\u5b83\uff0cRails \u548c React (TypeScript \u90e8\u5206) \u7684\u5b9a\u4e49\u5c06\u901a\u8fc7 JSON Schema \u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"k\">import<\/span> <span class=\"p\">{<\/span> <span class=\"nx\">HelloComponentProps<\/span> <span class=\"p\">}<\/span> <span class=\"k\">from<\/span> <span class=\"dl\">\"<\/span><span class=\"s2\">.\/generated-types-from-json-schema\/HelloComponent<\/span><span class=\"dl\">\"<\/span>\r\n\r\n<span class=\"kd\">const<\/span> <span class=\"nx\">HelloComponent<\/span> <span class=\"o\">=<\/span> <span class=\"p\">({<\/span> <span class=\"nx\">name<\/span> <span class=\"p\">}:<\/span> <span class=\"nx\">HelloComponentProps<\/span><span class=\"p\">)<\/span> <span class=\"o\">=&gt;<\/span> <span class=\"p\">{<\/span>\r\n  <span class=\"k\">return <\/span><span class=\"p\">(&lt;<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;<\/span>Hello, <span class=\"si\">{<\/span><span class=\"nx\">name<\/span><span class=\"si\">}<\/span>!<span class=\"p\">&lt;\/<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;)<\/span>\r\n<span class=\"p\">}<\/span>\r\n<span class=\"nx\">ReactOnRails<\/span><span class=\"p\">.<\/span><span class=\"nf\">register<\/span><span class=\"p\">({<\/span> <span class=\"nx\">HelloWorld<\/span> <span class=\"p\">})<\/span>\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e00\u5207\u53ef\u4ee5\u5728\u6bcf\u79cd\u8bed\u8a00\u4e2d\u8fdb\u884c\u81ea\u8eab\u5904\u7406\u7684\u9a8c\u8bc1\uff0c\u4f7f\u5f97\u66f4\u5bb9\u6613\u8fdb\u884c\u64cd\u4f5c\u9a8c\u8bc1\uff0c\u4ece\u800c\u66f4\u5bb9\u6613\u4e14\u5b89\u5168\u5730\u4f7f\u7528 React on Rails\u3002<\/p>\n<h3>\u203b\u8bbe\u8ba1\u4e0e\u5b9e\u65bd\u7b56\u7565<\/h3>\n<h4>\u5c06 View \u8f6c\u5316\u4e3a React \u7ec4\u4ef6\uff0c\u65b9\u4fbf\u8fdb\u884c\u64cd\u4f5c\u9a8c\u8bc1<\/h4>\n<p>\u6211\u4f1a\u7b80\u8981\u63d0\u53ca\u8fd9\u4e2a\u8bbe\u8ba1\u7684\u610f\u56fe\u6240\u5728\u3002<\/p>\n<p>\u4e3a\u4e86\u4f7f\u4f7f\u7528\u66f4\u52a0\u65b9\u4fbf\uff0cQiita Team\u6b63\u5728\u63a8\u52a8\u754c\u9762\u7684\u66f4\u65b0\uff0c\u5305\u62ec\u4e3b\u9875\u7684\u91cd\u65b0\u8bbe\u8ba1\u3002\u4e0e\u6b64\u540c\u65f6\uff0c\u6211\u4eec\u4e5f\u5728\u63a8\u52a8\u524d\u7aef\u7684React\u5316\u3002\u4ee5\u524d\uff0c\u89c6\u56fe\u90e8\u5206\u6709\u4e9b\u662f\u7528Rails\uff08Slim\uff09\u7f16\u5199\u7684\uff0c\u6709\u4e9b\u662f\u7528React\u7f16\u5199\u7684\uff0c\u73b0\u5728\u6211\u4eec\u6b63\u5728\u52aa\u529b\u5c06\u5927\u90e8\u5206\u5185\u5bb9\u66ff\u6362\u4e3aReact\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86React On Rails\u6765\u59d4\u6258\u6e32\u67d3\u7ed9React\u3002<\/p>\n<p>\u5728\u90a3\u4e2a\u65f6\u5019\uff0c\u6700\u56f0\u6270\u6211\u7684\u662f\u4eceRails\uff08React On Rails\uff09\u5230JavaScript\uff08React\uff09\u4f20\u9012\u6570\u636e\u7684\u4e0d\u660e\u786e\u6027\u3002\u5f53\u4f7f\u7528React On Rails\u5c06\u6570\u636e\u4f20\u9012\u7ed9JavaScript\u65f6\uff0c\u6211\u4eec\u4f7f\u7528\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u5bf9\u8c61\u6307\u5b9a\u6570\u636e\uff0c\u4f46\u65e0\u6cd5\u4fdd\u8bc1\u8fd9\u4e0eReact\u65b9\u9762\u671f\u671b\u7684\u503c\u4e00\u81f4\uff0c\u6709\u65f6\u5019\uff08\u5b9e\u9645\u4e0a\uff09\u4f1a\u6709\u504f\u5dee\uff0c\u4f20\u9012\u7684\u6570\u636e\u4e5f\u4e0d\u660e\u786e\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"cp\">&lt;%=<\/span> <span class=\"n\">react_component<\/span><span class=\"p\">(<\/span><span class=\"s2\">\"HelloComponent\"<\/span><span class=\"p\">,<\/span> <span class=\"ss\">props: <\/span><span class=\"p\">{<\/span> <span class=\"ss\">name: <\/span><span class=\"s2\">\"Taro\"<\/span> <span class=\"p\">})<\/span> <span class=\"cp\">%&gt;<\/span>\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/49-0.png\" alt=\"view.drawio.png\" \/><\/div>\n<p>\u56e0\u4e3a\u8fd9\u79cd\u60c5\u51b5\uff0c<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u578b\u304c\u4fe1\u7528\u3067\u304d\u306a\u3044<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30c6\u30b9\u30c8\u3092\u3059\u308b\u305f\u3081\u306b\u3001 Rails, JavaScript \u4e21\u65b9\u3092\u5b9f\u884c\u3059\u308b\u3088\u3046\u306a\u30c6\u30b9\u30c8 (Feature Spec, System Spec, Server Side Rendering \u3092\u5229\u7528\u3059\u308b) \u304c\u5fc5\u8981\u306b\u306a\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>React \u3092\u4f7f\u7528\u3059\u308b\u7b87\u6240\u3067\u5168\u3066\u3053\u308c\u306b\u306a\u308b\u3068\u3001\u30c6\u30b9\u30c8\u304c\u975e\u5e38\u306b\u8907\u96d1\u5316\u3059\u308b<\/p>\n<p>\u5728\u8fd9\u4e2a\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5b58\u5728\u95ee\u9898\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u4f5c\u4e3a\u6539\u8fdb\uff0c\u6211\u4eec\u91c7\u53d6\u7684\u65b9\u6cd5\u662f\u5728\u4f20\u64ad\u6240\u4ecb\u7ecd\u7684 React On Rails \u7684\u4fe1\u606f\u4e2d\uff0c\u4f7f\u7528 JSON Schema \u63d0\u4f9b\u6a21\u5f0f\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/54-0.png\" alt=\"json_schema.drawio.png\" \/><\/div>\n<p>\u901a\u8fc7\u4f7f\u7528JSON Schema\u6765\u786e\u4fdd\u4f20\u9012\u7684\u4fe1\u606f\u7684\u51c6\u786e\u6027\uff0c\u6211\u4eec\u4e0d\u518d\u9700\u8981\u4e3aRails\u548cJavaScript\u5206\u522b\u51c6\u5907\u5904\u7406\u7cfb\u7edf\uff0c\u800c\u662f\u53ef\u4ee5\u5728\u5404\u81ea\u7cfb\u7edf\u4e2d\u68c0\u67e5\u5176\u51c6\u786e\u6027\u3002\u6b64\u5916\uff0c\u7531\u4e8e\u53ef\u4ee5\u4eceSchema\u751f\u6210\u7c7b\u578b\uff0c\u7c7b\u578b\u4e5f\u53d8\u5f97\u66f4\u53ef\u4fe1\u3002<\/p>\n<p>\u901a\u8fc7\u8fd9\u4e00\u4e3e\u63aa\uff0c\u5373\u4f7f\u8fc1\u79fb\u5230React\uff0c\u6d4b\u8bd5\u4e5f\u4e0d\u4f1a\u53d8\u5f97\u590d\u6742\uff0c\u5e76\u4e14\u4ee3\u7801\u7c7b\u578b\u4e5f\u53d8\u5f97\u53ef\u9760\uff0c\u4f7f\u5f97\u66ff\u6362\u4e3aReact\u5e76\u8fdb\u884c\u5f00\u53d1\u53d8\u5f97\u975e\u5e38\u5bb9\u6613\u3002<\/p>\n<h4>\u901a\u8fc7\u7ed3\u5408\u73b0\u6709\u6280\u672f\u548c\u7ecf\u9a8c\uff0c\u6709\u6548\u5730\u63d0\u5347\u4f53\u9a8c\u7684\u6539\u5584\u3002<\/h4>\n<p>\u5728\u5f00\u53d1\u548c\u5f15\u5165JsonSchemaView\u65f6\uff0c\u6211\u4eec\u975e\u5e38\u91cd\u89c6\u4e0eQiita\u516c\u53f8\u5185\u90e8\u7684\u6280\u672f\u548c\u5f00\u53d1\u7ecf\u9a8c\u7684\u8fde\u7eed\u6027\uff0c\u4ee5\u964d\u4f4e\u56e2\u961f\u6210\u5458\u5b66\u4e60\u548c\u638c\u63e1\u5b83\u7684\u96be\u5ea6\uff0c\u8ba9\u4ed6\u4eec\u80fd\u591f\u5c3d\u5feb\u611f\u53d7\u5230\u65b0\u5de5\u4f5c\u6d41\u7684\u597d\u5904\uff0c\u5e76\u80fd\u591f\u4ee5\u8f83\u4f4e\u7684\u6210\u672c\u9010\u6b65\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<p>\u7531\u4e8e\u4f7f\u7528Schema\u7684\u5f00\u53d1\u5de5\u4f5c\u6d41\u53ef\u80fd\u51fa\u73b0\u5404\u79cd\u5404\u6837\u7684\u5de5\u5177\u548c\u5b66\u4e60\u6210\u672c\u8f83\u9ad8\u7684\u95ee\u9898\uff0c\u6211\u8ba4\u4e3a\u7279\u522b\u9700\u8981\u6ce8\u610f\u3002<\/p>\n<p>\u4e3e\u4f8b\u6765\u8bf4\uff0cQiita\u516c\u53f8\u4f7f\u7528GraphQL Ruby\u548cJsonWorld\u7b49\u5de5\u5177\uff0c\u5e76\u5177\u6709\u901a\u8fc7\u6240\u8c13\u7684\u4ee3\u7801\u4f18\u5148\u65b9\u5f0f\u5b9a\u4e49\u6a21\u5f0f\u7684\u7ecf\u9a8c\u3002<br \/>\n\u6b64\u5916\uff0c\u4ed6\u4eec\u8fd8\u5c1d\u8bd5\u901a\u8fc7\u81ea\u52a8\u751f\u6210TypeScript\u7c7b\u578b\u5b9a\u4e49\u6765\u5efa\u7acbGraphQL API\uff0c\u5e76\u5728\u5176\u4ed6API\u7684\u67d0\u4e9b\u90e8\u5206\u8bd5\u9a8c\u6027\u5730\u4f7f\u7528JSON Schema\u8fdb\u884c\u751f\u6210\u3002<\/p>\n<p>\u53ef\u4ee5\u6e32\u67d3\u51fa\u6765\u7684\u5bf9\u8c61\u662f\u53c2\u8003\u4e86ViewComponent\u7684\u601d\u8def\uff0c\u4f46\u5728\u4e0b\u9762\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u8be5\u65b9\u6cd5\u548c\u4f18\u70b9\uff0c\u4ee5\u53ca\u4e0e\u5176\u7ec4\u5408\u7684\u6280\u672f\u548c\u65b9\u6cd5\uff0c\u800c\u4e14\u8fd9\u4e9b\u6280\u672f\u548c\u65b9\u6cd5\u90fd\u662f\u6211\u4eec\u4ee5\u524d\u89c1\u8fc7\u6216\u4f7f\u7528\u8fc7\u7684\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u6211\u4eec\u91c7\u7528\u5c06\u5b83\u4eec\u7ec4\u5408\u8d77\u6765\u5e76\u9644\u4e0a\u4e00\u4e9b\u989d\u5916\u7684\u6539\u8fdb\u6765\u8fdb\u884c\u5bfc\u5165\u548c\u5f00\u53d1\u7684\u65b9\u5f0f\u3002<\/p>\n<p>\u91c7\u53d6\u8fd9\u79cd\u5bfc\u5165\u65b9\u6cd5\u662f\u56e0\u4e3a\u5728\u5f00\u53d1\u8fd9\u4e2a\u529f\u80fd\u7684\u65f6\u5019\uff0c\u6211\u4eec\u5df2\u7ecf\u4ee5\u5916\u5305\u7684\u5f62\u5f0f\u53c2\u4e0e\u5176\u4e2d\uff0c\u5e76\u4e14\u5728\u5bfc\u5165\u8fc7\u7a0b\u4e2d\u5f88\u96be\u82b1\u8d39\u5927\u91cf\u65f6\u95f4\u6765\u652f\u6301\u3002\u4f46\u662f\u901a\u8fc7\u91c7\u53d6\u8fd9\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u5728\u5185\u90e8\u4e5f\u80fd\u591f\u611f\u53d7\u5230\u65b9\u4fbf\u6027\uff0c\u5e76\u6210\u529f\u5730\u589e\u52a0\u4e86\u7528\u6237\u6570\u91cf\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u901a\u8fc7\u5c06JSON Schema\u548cReact on Rails\u7ed3\u5408\u4f7f\u7528\uff0c\u4ee5\u4fbf\u66f4\u5bb9\u6613\u8fdb\u884c\u64cd\u4f5c\u9a8c\u8bc1\u7684\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5b9e\u73b0\u8fd9\u4e00\u65b9\u6cd5\u7684JsonSchemaView\u3002<\/p>\n<p>\u73b0\u4ee3Rails\u5e94\u7528\u7684\u524d\u7aef\u60c5\u51b5\u5341\u5206\u590d\u6742\u4e14\u5404\u4e0d\u76f8\u540c\uff0c\u56e0\u6b64\u76f4\u63a5\u5229\u7528\u672c\u6b21\u65b9\u6cd5\u53ef\u80fd\u4f1a\u6709\u4e00\u5b9a\u56f0\u96be\uff0c\u4f46\u662f\u4f7f\u7528\u67b6\u6784\u5f00\u53d1\u5177\u6709\u66f4\u5e7f\u6cdb\u7684\u5e94\u7528\u8303\u56f4\uff0c\u5982\u679c\u80fd\u591f\u719f\u7ec3\u638c\u63e1\uff0c\u53ef\u4ee5\u53d1\u6325\u5de8\u5927\u7684\u4ef7\u503c\u3002\u5e0c\u671b\u8fd9\u79cd\u65b9\u6cd5\u548c\u5f15\u5165\u65b9\u5f0f\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<hr \/>\n<p>\u5982\u679c\u4f60\u5bf9\u8fd9\u65b9\u9762\u7684\u8bdd\u9898\u611f\u5174\u8da3\u5e76\u5e0c\u671b\u4e86\u89e3\u66f4\u591a\uff0c\u6211\u4e5f\u53d1\u5e03\u4e86\u6709\u5173Dev\u7684\u8ba8\u8bba\u3002\u65e0\u8bba\u662f\u5728\u7ebf\u8fd8\u662f\u7ebf\u4e0b\uff0c\u90fd\u53ef\u4ee5\u4ea4\u6d41\u3002\u6240\u4ee5\u8bf7\u52a1\u5fc5\u70b9\u51fb\u4e0b\u65b9\u7684\u201c\u60f3\u8981\u4ea4\u6d41\u201d\u6309\u94ae\uff0c\u4e0e\u6211\u4eec\u8ba8\u8bba\u5427\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u662f\u300eQiita\u516c\u53f8Advent Calendar 2022\u300f\u7684\u7b2c15\u5929\u7684\u6587\u7ae0\u3002 \u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8eRails [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-38339","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168 - Blog - Silicon Cloud<\/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.silicloud.com\/zh\/blog\/\u901a\u8fc7\u4f7f\u7528json-schema\u7684\u529f\u80fd\uff0c\u4f7freact-on-rails\u66f4\u5b89\u5168\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168\" \/>\n<meta property=\"og:description\" content=\"\u672c\u7bc7\u6587\u7ae0\u662f\u300eQiita\u516c\u53f8Advent Calendar 2022\u300f\u7684\u7b2c15\u5929\u7684\u6587\u7ae0\u3002 \u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8eRails [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7\u4f7f\u7528json-schema\u7684\u529f\u80fd\uff0c\u4f7freact-on-rails\u66f4\u5b89\u5168\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-07T02:57:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-03T20:57:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/14-0.png\" \/>\n<meta name=\"author\" content=\"\u96c5, \u609f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u96c5, \u609f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/\",\"name\":\"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2022-11-07T02:57:12+00:00\",\"dateModified\":\"2024-05-03T20:57:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6\",\"name\":\"\u96c5, \u609f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g\",\"caption\":\"\u96c5, \u609f\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168 - Blog - Silicon Cloud","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.silicloud.com\/zh\/blog\/\u901a\u8fc7\u4f7f\u7528json-schema\u7684\u529f\u80fd\uff0c\u4f7freact-on-rails\u66f4\u5b89\u5168\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168","og_description":"\u672c\u7bc7\u6587\u7ae0\u662f\u300eQiita\u516c\u53f8Advent Calendar 2022\u300f\u7684\u7b2c15\u5929\u7684\u6587\u7ae0\u3002 \u4f5c\u4e3a\u4e00\u79cd\u7528\u4e8eRails [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u901a\u8fc7\u4f7f\u7528json-schema\u7684\u529f\u80fd\uff0c\u4f7freact-on-rails\u66f4\u5b89\u5168\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2022-11-07T02:57:12+00:00","article_modified_time":"2024-05-03T20:57:08+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d335537434c4406c6521b\/14-0.png"}],"author":"\u96c5, \u609f","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u96c5, \u609f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/","name":"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2022-11-07T02:57:12+00:00","dateModified":"2024-05-03T20:57:08+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u901a\u8fc7\u4f7f\u7528JSON Schema\u7684\u529f\u80fd\uff0c\u4f7fReact on Rails\u66f4\u5b89\u5168"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/f044a4b7fa4ee2701702942002419ca6","name":"\u96c5, \u609f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e71a913e914f1aad1efc391f92084294bac54bc782acd289638580134cf667a6?s=96&d=mm&r=g","caption":"\u96c5, \u609f"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yawu\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e9%80%9a%e8%bf%87%e4%bd%bf%e7%94%a8json-schema%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%8c%e4%bd%bfreact-on-rails%e6%9b%b4%e5%ae%89%e5%85%a8%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=38339"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38339\/revisions"}],"predecessor-version":[{"id":96248,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/38339\/revisions\/96248"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=38339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=38339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=38339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}