{"id":329278,"date":"2023-01-29T00:30:04","date_gmt":"2023-01-28T16:30:04","guid":{"rendered":"https:\/\/www.idc.net\/help\/329278\/"},"modified":"2023-01-29T00:30:04","modified_gmt":"2023-01-28T16:30:04","slug":"%e5%be%ae%e6%9c%8d%e5%8a%a1%e7%9a%84%e7%89%88%e6%9c%ac%e5%8f%b7%e8%a6%81%e6%80%8e%e4%b9%88%e8%ae%be%e8%ae%a1%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/329278\/","title":{"rendered":"\u5fae\u670d\u52a1\u7684\u7248\u672c\u53f7\u8981\u600e\u4e48\u8bbe\u8ba1\uff1f"},"content":{"rendered":"<p style=\"text-align: justify\">\u4eca\u5929\u6211\u4eec\u6765\u804a\u4e00\u4e0b\u5fae\u670d\u52a1\u9879\u76ee\u4e2d\u7684\u7248\u672c\u53f7\u8981\u600e\u4e48\u8bbe\u8ba1\u3002<\/p>\n<p style=\"text-align: justify\">\u5c0f\u4f19\u4f34\u4eec\u5e73\u65f6\u770b\u5230\u7684\u9879\u76ee\u7248\u672c\u53f7\uff0c\u57fa\u672c\u4e0a\u90fd\u662f\u5206\u4e3a\u4e86\u4e09\u90e8\u5206&nbsp;X.Y.Z\uff0c\u7248\u672c\u5347\u7ea7\u7684\u65f6\u5019\u7248\u672c\u53f7\u90fd\u4f1a\u53d8\uff0c\u90a3\u4e48\u7248\u672c\u53f7\u600e\u4e48\u53d8\uff0c\u8fd9\u53ef\u4e0d\u662f\u62cd\u8111\u95e8\u51b3\u5b9a\u7684\uff0c\u4eca\u5929\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u63a2\u8ba8\u4e00\u4e0b\u8fd9\u4e2a\u8bdd\u9898\u3002<\/p>\n<h4>## 1. \u8bed\u4e49\u5316\u7248\u672c\u63a7\u5236\u89c4\u8303<\/h4>\n<p style=\"text-align: justify\">\u7248\u672c\u53f7\u8be5\u5982\u4f55\u63a7\u5236\uff1f\u5176\u5b9e\u662f\u6709\u4e00\u4e2a\u6807\u51c6\u89c4\u8303\u7684\uff0c\u89c4\u8303\u5730\u5740\uff1a\u200b\u200bhttps:\/\/semver.org\/lang\/zh-CN\/\u200b\u200b<\/p>\n<p style=\"text-align: justify\">\u8fd9\u4e2a\u89c4\u8303\u975e\u5e38\u53cb\u597d\u7684\u63d0\u4f9b\u4e86\u4e2d\u6587\u7248\u7684\u5185\u5bb9\u3002<\/p>\n<p style=\"text-align: justify\">\u8bed\u4e49\u5316\u7684\u7248\u672c\u63a7\u5236\u89c4\u8303\u8981\u6c42\u7248\u672c\u53f7\u7531\u4e09\u90e8\u5206\u6784\u6210\uff1a<\/p>\n<p style=\"text-align: justify\">MAJOR\uff08X\uff09\uff1a\u8fd9\u4e2a\u662f\u4e3b\u7248\u672c\u53f7\uff0c\u4e00\u822c\u662f\u6d89\u53ca\u5230\u4e0d\u517c\u5bb9\u7684 API \u66f4\u6539\u65f6\uff0c\u8fd9\u4e2a\u4f1a\u53d8\u5316\u3002<\/p>\n<p style=\"text-align: justify\">MINOR\uff08Y\uff09\uff1a\u8fd9\u4e2a\u662f\u6b21\u7248\u672c\u53f7\uff0c\u5f53\u6211\u4eec\u5bf9 API \u8fdb\u884c\u5411\u540e\u517c\u5bb9\u7684\u589e\u5f3a\u65f6\uff0c\u8fd9\u4e2a\u7248\u672c\u53f7\u4f1a\u53d8\u5316\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u4e5f\u5c31\u662f\u6709\u65b0\u589e\u7684\u529f\u80fd\u65f6\uff0c\u8fd9\u91cc\u4f1a\u53d8\u5316\u3002<\/p>\n<p style=\"text-align: justify\">PATCH\uff08Z\uff09\uff1a\u8fd9\u4e2a\u662f\u4fee\u8ba2\u53f7\uff0c\u5f53\u6211\u4eec\u8fdb\u884c\u4e00\u4e9b BUG \u7684\u4fee\u590d\uff0c\u7136\u540e\u8981\u53d1\u7248\u7684\u65f6\u5019\uff0c\u8fd9\u91cc\u4f1a\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<p style=\"text-align: justify\">\u8bed\u4e49\u5316\u7684\u7248\u672c\u63a7\u5236\u89c4\u8303\u4e3b\u8981\u505a\u4e86\u5982\u4e0b\u4e00\u4e9b\u8981\u6c42\uff1a<\/p>\n<p style=\"text-align: justify\">\u4f7f\u7528\u8bed\u4e49\u5316\u7248\u672c\u63a7\u5236\u7684\u8f6f\u4ef6\u5fc5\u987b\uff08MUST\uff09\u5b9a\u4e49\u516c\u5171 API\u3002\u8be5 API \u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u88ab\u5b9a\u4e49\u6216\u51fa\u73b0\u4e8e\u4e25\u8c28\u7684\u6587\u6863\u5185\u3002\u65e0\u8bba\u4f55\u79cd\u5f62\u5f0f\u90fd\u5e94\u8be5\u529b\u6c42\u7cbe\u786e\u4e14\u5b8c\u6574\u3002<\/p>\n<p style=\"text-align: justify\">\u6807\u51c6\u7684\u7248\u672c\u53f7\u5fc5\u987b\uff08MUST\uff09\u91c7\u7528&nbsp;X.Y.Z&nbsp;\u7684\u683c\u5f0f\uff0c\u5176\u4e2d X\u3001Y \u548c Z \u4e3a\u975e\u8d1f\u7684\u6574\u6570\uff0c\u4e14\u7981\u6b62\uff08MUST NOT\uff09\u5728\u6570\u5b57\u524d\u65b9\u8865\u96f6\u3002X \u662f\u4e3b\u7248\u672c\u53f7\u3001Y \u662f\u6b21\u7248\u672c\u53f7\u3001\u800c Z \u4e3a\u4fee\u8ba2\u53f7\u3002\u6bcf\u4e2a\u5143\u7d20\u5fc5\u987b\uff08MUST\uff09\u4ee5\u6570\u503c\u6765\u9012\u589e\u3002\u4f8b\u5982\uff1a1.9.1 -&gt; 1.10.0 -&gt; 1.11.0\u3002<\/p>\n<p style=\"text-align: justify\">\u6807\u8bb0\u7248\u672c\u53f7\u7684\u8f6f\u4ef6\u53d1\u884c\u540e\uff0c\u7981\u6b62\uff08MUST NOT\uff09\u6539\u53d8\u8be5\u7248\u672c\u8f6f\u4ef6\u7684\u5185\u5bb9\u3002\u4efb\u4f55\u4fee\u6539\u90fd\u5fc5\u987b\uff08MUST\uff09\u4ee5\u65b0\u7248\u672c\u53d1\u884c\u3002\u6709\u7684\u5c0f\u4f19\u4f34\u53ef\u80fd\u4f1a\u8bf4\u6211\u4eec\u7684\u9879\u76ee\u5904\u4e8e\u5feb\u901f\u5f00\u53d1\u9636\u6bb5\uff0cAPI \u4e0d\u7a33\u5b9a\uff0c\u5929\u5929\u53d8\uff0c\u8981\u662f\u6309\u7167\u8fd9\u4e2a\u8981\u6c42\u6765\u5f97\u53d1\u591a\u5c11\u4e2a\u7248\u672c\u624d\u591f\u7528\u5440\uff01\u5176\u5b9e\uff0c\u4e00\u822c API \u5feb\u901f\u53d8\u5316\u4e3b\u8981\u6709\u4e24\u79cd\u60c5\u51b5\uff0c\u4e00\u79cd\u662f\u9879\u76ee\u521a\u7acb\u9879\u7684\u65f6\u5019\uff0c\u6b64\u65f6\u4e3b\u7248\u672c\u53f7\u4e3a 0\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019\u7684 API \u5c31\u4e0d\u80fd\u7b97\u662f\u7a33\u5b9a\u7684 API\uff1b\u53e6\u5916\u4e00\u79cd\u60c5\u51b5\u5219\u662f\u4e0b\u4e2a\u4e3b\u7248\u672c\u5904\u4e8e\u5feb\u901f\u5f00\u53d1\u4e2d\uff0c\u4f46\u662f\u8fd9\u79cd\u60c5\u51b5\u4e00\u822c\u4f1a\u6709\u4e00\u4e2a\u65b0\u7684\u5206\u652f\u7528\u6765\u7ba1\u7406\u4e0b\u4e2a\u7248\u672c\u7684\u4ee3\u7801\uff0c\u6240\u4ee5\u548c\u8fd9\u91cc\u7684\u8981\u6c42\u5b9e\u9645\u4e0a\u5e76\u4e0d\u51b2\u7a81\uff08\u5177\u4f53\u53c2\u89c1\u7b2c 4\u30015 \u6761\uff09\u3002<\/p>\n<p style=\"text-align: justify\">\u4e3b\u7248\u672c\u53f7\u4e3a\u96f6\uff080.y.z\uff09\u7684\u8f6f\u4ef6\u5904\u4e8e\u5f00\u53d1\u521d\u59cb\u9636\u6bb5\uff0c\u4e00\u5207\u90fd\u53ef\u80fd\u968f\u65f6\u88ab\u6539\u53d8\u3002\u8fd9\u6837\u7684\u516c\u5171 API \u4e0d\u5e94\u8be5\u88ab\u89c6\u4e3a\u7a33\u5b9a\u7248\u3002<\/p>\n<p style=\"text-align: justify\">1.0.0 \u7684\u7248\u672c\u53f7\u7528\u4e8e\u754c\u5b9a\u516c\u5171 API \u7684\u5f62\u6210\u3002\u8fd9\u4e00\u7248\u672c\u4e4b\u540e\u6240\u6709\u7684\u7248\u672c\u53f7\u66f4\u65b0\u90fd\u57fa\u4e8e\u516c\u5171 API \u53ca\u5176\u4fee\u6539\u5185\u5bb9\u3002\u90a3\u4e48\u6709\u7684\u5c0f\u4f19\u4f34\u53ef\u80fd\u4f1a\u7ea0\u7ed3\u4ec0\u4e48\u65f6\u5019\u7248\u672c\u53f7\u4ece 0.Y.Z \u53d8\u4e3a 1.Y.Z \u5462\uff1f\u4e00\u822c\u6765\u8bf4\uff0c\u5f53\u4f60\u7684\u9879\u76ee\u5df2\u7ecf\u4e0a\u4e86\u751f\u4ea7\u73af\u5883\u6216\u8005\u8bf4\u6709\u7a33\u5b9a\u7684 API \u63d0\u4f9b\u7ed9\u522b\u4eba\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u57fa\u672c\u4e0a\u5c31\u53ef\u4ee5\u7b97\u662f 1.Y.Z \u4e86\u3002<\/p>\n<p style=\"text-align: justify\">\u4fee\u8ba2\u53f7 Z\uff08x.y.Z | x &gt; 0\uff09\u5fc5\u987b\uff08MUST\uff09\u5728\u53ea\u505a\u4e86\u5411\u4e0b\u517c\u5bb9\u7684\u4fee\u6b63\u65f6\u624d\u9012\u589e\u3002\u8fd9\u91cc\u7684\u4fee\u6b63\u6307\u7684\u662f\u9488\u5bf9\u4e0d\u6b63\u786e\u7ed3\u679c\u800c\u8fdb\u884c\u7684\u5185\u90e8\u4fee\u6539\u3002<\/p>\n<p style=\"text-align: justify\">\u6b21\u7248\u672c\u53f7 Y\uff08x.Y.z | x &gt; 0\uff09\u5fc5\u987b\uff08MUST\uff09\u5728\u6709\u5411\u4e0b\u517c\u5bb9\u7684\u65b0\u529f\u80fd\u51fa\u73b0\u65f6\u9012\u589e\u3002\u5728\u4efb\u4f55\u516c\u5171 API \u7684\u529f\u80fd\u88ab\u6807\u8bb0\u4e3a\u5f03\u7528\u65f6\u4e5f\u5fc5\u987b\uff08MUST\uff09\u9012\u589e\u3002\u4e5f\u53ef\u4ee5\uff08MAY\uff09\u5728\u5185\u90e8\u7a0b\u5e8f\u6709\u5927\u91cf\u65b0\u529f\u80fd\u6216\u6539\u8fdb\u88ab\u52a0\u5165\u65f6\u9012\u589e\uff0c\u5176\u4e2d\u53ef\u4ee5\uff08MAY\uff09\u5305\u62ec\u4fee\u8ba2\u7ea7\u522b\u7684\u6539\u53d8\u3002\u6bcf\u5f53\u6b21\u7248\u672c\u53f7\u9012\u589e\u65f6\uff0c\u4fee\u8ba2\u53f7\u5fc5\u987b\uff08MUST\uff09\u5f52\u96f6\u3002<\/p>\n<p style=\"text-align: justify\">\u4e3b\u7248\u672c\u53f7 X\uff08X.y.z | X &gt; 0\uff09\u5fc5\u987b\uff08MUST\uff09\u5728\u6709\u4efb\u4f55\u4e0d\u517c\u5bb9\u7684\u4fee\u6539\u88ab\u52a0\u5165\u516c\u5171 API \u65f6\u9012\u589e\u3002\u5176\u4e2d\u53ef\u4ee5\uff08MAY\uff09\u5305\u62ec\u6b21\u7248\u672c\u53f7\u53ca\u4fee\u8ba2\u7ea7\u522b\u7684\u6539\u53d8\u3002\u6bcf\u5f53\u4e3b\u7248\u672c\u53f7\u9012\u589e\u65f6\uff0c\u6b21\u7248\u672c\u53f7\u548c\u4fee\u8ba2\u53f7\u5fc5\u987b\uff08MUST\uff09\u5f52\u96f6\u3002<\/p>\n<p style=\"text-align: justify\">\u5148\u884c\u7248\u672c\u53f7\u53ef\u4ee5\uff08MAY\uff09\u88ab\u6807\u6ce8\u5728\u4fee\u8ba2\u7248\u4e4b\u540e\uff0c\u5148\u52a0\u4e0a\u4e00\u4e2a\u8fde\u63a5\u53f7\u518d\u52a0\u4e0a\u4e00\u8fde\u4e32\u4ee5\u53e5\u70b9\u5206\u9694\u7684\u6807\u8bc6\u7b26\u6765\u4fee\u9970\u3002\u6807\u8bc6\u7b26\u5fc5\u987b\uff08MUST\uff09\u7531 ASCII \u5b57\u6bcd\u6570\u5b57\u548c\u8fde\u63a5\u53f7 [0-9A-Za-z-] \u7ec4\u6210\uff0c\u4e14\u7981\u6b62\uff08MUST NOT\uff09\u7559\u767d\u3002\u6570\u5b57\u578b\u7684\u6807\u8bc6\u7b26\u7981\u6b62\uff08MUST NOT\uff09\u5728\u524d\u65b9\u8865\u96f6\u3002\u5148\u884c\u7248\u7684\u4f18\u5148\u7ea7\u4f4e\u4e8e\u76f8\u5173\u8054\u7684\u6807\u51c6\u7248\u672c\u3002\u88ab\u6807\u4e0a\u5148\u884c\u7248\u672c\u53f7\u5219\u8868\u793a\u8fd9\u4e2a\u7248\u672c\u5e76\u975e\u7a33\u5b9a\u800c\u4e14\u53ef\u80fd\u65e0\u6cd5\u6ee1\u8db3\u9884\u671f\u7684\u517c\u5bb9\u6027\u9700\u6c42\u3002\u8303\u4f8b\uff1a1.0.0-alpha\u30011.0.0-alpha.1\u30011.0.0-0.3.7\u30011.0.0-x.7.z.92\u3002<\/p>\n<p style=\"text-align: justify\">\u7248\u672c\u7f16\u8bd1\u4fe1\u606f\u53ef\u4ee5\uff08MAY\uff09\u88ab\u6807\u6ce8\u5728\u4fee\u8ba2\u7248\u6216\u5148\u884c\u7248\u672c\u53f7\u4e4b\u540e\uff0c\u5148\u52a0\u4e0a\u4e00\u4e2a\u52a0\u53f7\u518d\u52a0\u4e0a\u4e00\u8fde\u4e32\u4ee5\u53e5\u70b9\u5206\u9694\u7684\u6807\u8bc6\u7b26\u6765\u4fee\u9970\u3002\u6807\u8bc6\u7b26\u5fc5\u987b\uff08MUST\uff09\u7531 ASCII \u5b57\u6bcd\u6570\u5b57\u548c\u8fde\u63a5\u53f7 [0-9A-Za-z-] \u7ec4\u6210\uff0c\u4e14\u7981\u6b62\uff08MUST NOT\uff09\u7559\u767d\u3002\u5f53\u5224\u65ad\u7248\u672c\u7684\u4f18\u5148\u5c42\u7ea7\u65f6\uff0c\u7248\u672c\u7f16\u8bd1\u4fe1\u606f\u53ef\uff08SHOULD\uff09\u88ab\u5ffd\u7565\u3002\u56e0\u6b64\u5f53\u4e24\u4e2a\u7248\u672c\u53ea\u6709\u5728\u7248\u672c\u7f16\u8bd1\u4fe1\u606f\u6709\u5dee\u522b\u65f6\uff0c\u5c5e\u4e8e\u76f8\u540c\u7684\u4f18\u5148\u5c42\u7ea7\u3002\u8303\u4f8b\uff1a1.0.0-alpha+001\u30011.0.0+20130313144700\u30011.0.0-beta+exp.sha.5114f85\u3002<\/p>\n<p style=\"text-align: justify\">\u7248\u672c\u7684\u4f18\u5148\u5c42\u7ea7\u6307\u7684\u662f\u4e0d\u540c\u7248\u672c\u5728\u6392\u5e8f\u65f6\u5982\u4f55\u6bd4\u8f83\u3002<\/p>\n<p style=\"text-align: justify\">\u53ea\u6709\u6570\u5b57\u7684\u6807\u8bc6\u7b26\u4ee5\u6570\u503c\u9ad8\u4f4e\u6bd4\u8f83\u3002<\/p>\n<p style=\"text-align: justify\">\u6709\u5b57\u6bcd\u6216\u8fde\u63a5\u53f7\u65f6\u5219\u9010\u5b57\u4ee5 ASCII \u7684\u6392\u5e8f\u6765\u6bd4\u8f83\u3002<\/p>\n<p style=\"text-align: justify\">\u6570\u5b57\u7684\u6807\u8bc6\u7b26\u6bd4\u975e\u6570\u5b57\u7684\u6807\u8bc6\u7b26\u4f18\u5148\u5c42\u7ea7\u4f4e\u3002<\/p>\n<p style=\"text-align: justify\">\u82e5\u5f00\u5934\u7684\u6807\u8bc6\u7b26\u90fd\u76f8\u540c\u65f6\uff0c\u680f\u4f4d\u6bd4\u8f83\u591a\u7684\u5148\u884c\u7248\u672c\u53f7\u4f18\u5148\u5c42\u7ea7\u6bd4\u8f83\u9ad8\u3002\u4f8b\u5982\uff1a1.0.0-alpha &lt; 1.0.0-alpha.1 &lt; 1.0.0-alpha.beta &lt; 1.0.0-beta &lt; 1.0.0-beta.2 &lt; 1.0.0-beta.11 &lt; 1.0.0-rc.1 &lt; 1.0.0\u3002<\/p>\n<p style=\"text-align: justify\">\u5224\u65ad\u4f18\u5148\u5c42\u7ea7\u65f6\uff0c\u5fc5\u987b\uff08MUST\uff09\u628a\u7248\u672c\u4f9d\u5e8f\u62c6\u5206\u4e3a\u4e3b\u7248\u672c\u53f7\u3001\u6b21\u7248\u672c\u53f7\u3001\u4fee\u8ba2\u53f7\u53ca\u5148\u884c\u7248\u672c\u53f7\u540e\u8fdb\u884c\u6bd4\u8f83\uff08\u7248\u672c\u7f16\u8bd1\u4fe1\u606f\u4e0d\u5728\u8fd9\u4efd\u6bd4\u8f83\u7684\u5217\u8868\u4e2d\uff09\u3002<\/p>\n<p style=\"text-align: justify\">\u7531\u5de6\u5230\u53f3\u4f9d\u5e8f\u6bd4\u8f83\u6bcf\u4e2a\u6807\u8bc6\u7b26\uff0c\u7b2c\u4e00\u4e2a\u5dee\u5f02\u503c\u7528\u6765\u51b3\u5b9a\u4f18\u5148\u5c42\u7ea7\uff1a\u4e3b\u7248\u672c\u53f7\u3001\u6b21\u7248\u672c\u53f7\u53ca\u4fee\u8ba2\u53f7\u4ee5\u6570\u503c\u6bd4\u8f83\u3002\u4f8b\u5982\uff1a1.0.0 &lt; 2.0.0 &lt; 2.1.0 &lt; 2.1.1\u3002<\/p>\n<p style=\"text-align: justify\">\u5f53\u4e3b\u7248\u672c\u53f7\u3001\u6b21\u7248\u672c\u53f7\u53ca\u4fee\u8ba2\u53f7\u90fd\u76f8\u540c\u65f6\uff0c\u6539\u4ee5\u4f18\u5148\u5c42\u7ea7\u6bd4\u8f83\u4f4e\u7684\u5148\u884c\u7248\u672c\u53f7\u51b3\u5b9a\u3002\u4f8b\u5982\uff1a1.0.0-alpha &lt; 1.0.0\u3002<\/p>\n<p style=\"text-align: justify\">\u6709\u76f8\u540c\u4e3b\u7248\u672c\u53f7\u3001\u6b21\u7248\u672c\u53f7\u53ca\u4fee\u8ba2\u53f7\u7684\u4e24\u4e2a\u5148\u884c\u7248\u672c\u53f7\uff0c\u5176\u4f18\u5148\u5c42\u7ea7\u5fc5\u987b\uff08MUST\uff09\u900f\u8fc7\u7531\u5de6\u5230\u53f3\u7684\u6bcf\u4e2a\u88ab\u53e5\u70b9\u5206\u9694\u7684\u6807\u8bc6\u7b26\u6765\u6bd4\u8f83\uff0c\u76f4\u5230\u627e\u5230\u4e00\u4e2a\u5dee\u5f02\u503c\u540e\u51b3\u5b9a\uff1a<\/p>\n<h4>2. \u5fae\u670d\u52a1\u4e2d\u7684\u7248\u672c\u53f7<\/h4>\n<p style=\"text-align: justify\">\u90a3\u4e48\u5728\u5fae\u670d\u52a1\u4e2d\uff0c\u6211\u4eec\u7684\u7248\u672c\u53f7\u8be5\u600e\u4e48\u8bbe\u8ba1\u5462\uff1f<\/p>\n<p style=\"text-align: justify\">\u9996\u5148\uff0c\u6574\u4f53\u4e0a\u7684\u601d\u8def\uff0c\u5c31\u662f\u6309\u7167\u4e0a\u6587\u6240\u8bf4\u7684\u8bed\u4e49\u5316\u7248\u672c\u63a7\u5236\u89c4\u8303\u6765\u3002<\/p>\n<p style=\"text-align: justify\">\u5176\u6b21\uff0c\u4e0a\u9762\u867d\u7136\u7ed9\u51fa\u4e86\u5f88\u591a\u6761\u6761\u6846\u6846\uff0c\u7136\u800c\u6211\u4eec\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u4e00\u822c\u53ea\u9700\u8981\u4ece\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\u7b80\u5355\u8003\u8651\u5373\u53ef\uff0c\u6bcf\u6b21\u53d1\u7248\u7684\u65f6\u5019\u90fd\u53bb\u7ffb\u8fd9\u4e2a\u89c4\u8303\u663e\u7136\u4e5f\u4e0d\u73b0\u5b9e\uff1a<\/p>\n<p style=\"text-align: justify\">\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u5e94\u8be5\u53ea\u8fdb\u884c\u5411\u540e\u517c\u5bb9\u7684\u66f4\u65b0\u3002<\/p>\n<p style=\"text-align: justify\">\u6211\u4eec\u8981\u4e3a\u9879\u76ee\u6dfb\u52a0\u65b0\u529f\u80fd\u3001\u65b0\u7279\u6027\uff0c\u6211\u4eec\u5fc5\u987b\u8981\u8003\u8651\u5230\u9879\u76ee\u7684\u517c\u5bb9\u6027\u3002\u4f8b\u5982\u63a5\u53e3\u4e2d\u65b0\u52a0\u4e86\u4e00\u4e2a\u53c2\u6570\uff0c\u90a3\u4e48\u4e3a\u4e86\u8001\u7248\u672c\u7684\u5ba2\u6237\u7aef\u80fd\u591f\u987a\u5229\u8bbf\u95ee\u8fd9\u4e2a\u63a5\u53e3\uff0c\u670d\u52a1\u7aef\u5e94\u8be5\u8003\u8651\u4e3a\u8001\u7248\u672c\u5ba2\u6237\u7aef\u7f3a\u5c11\u7684\u8bf7\u6c42\u53c2\u6570\u63d0\u4f9b\u4e00\u4e2a\u9ed8\u8ba4\u503c\u3002\u6211\u4eec\u4e5f\u53ef\u80fd\u4e3a\u54cd\u5e94\u6dfb\u52a0\u65b0\u7684\u5c5e\u6027\uff0c\u6216\u8005\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b0\u7684\u63a5\u53e3\uff0c\u5f53\u7136\u8fd9\u4e9b\u4e00\u822c\u90fd\u4e0d\u5f71\u54cd\u8001\u5ba2\u6237\u7aef\u3002<\/p>\n<p style=\"text-align: justify\">\u5fc5\u987b\u8fdb\u884c\u4e0d\u517c\u5bb9\u7684\u5347\u7ea7\u3002<\/p>\n<p style=\"text-align: justify\">\u6709\u65f6\u5019\u6211\u4eec\u5fc5\u987b\u8fdb\u884c\u4e00\u4e9b\u4e0d\u517c\u5bb9\u7684\u5347\u7ea7\uff0c\u5bf9 API \u505a\u4e00\u4e9b\u4e3b\u8981\u7684\u4fee\u6539\uff0c\u8003\u8651\u5230\u5fae\u670d\u52a1\u4e4b\u95f4\u7684\u677e\u8026\u5408\u6027\uff0c\u6211\u4eec\u6ca1\u6cd5\u5f3a\u8feb\u5ba2\u6237\u7aef\u8fdb\u884c\u7acb\u9a6c\u5347\u7ea7\uff0c\u6b64\u65f6\u53ef\u80fd\u4f1a\u8003\u8651\u5728\u67d0\u4e00\u4e2a\u65f6\u95f4\u6bb5\u5185\uff0c\u4e24\u4e2a\u7248\u672c\u7684 API \u5171\u5b58\u3002<\/p>\n<p style=\"text-align: justify\">\u591a\u4e2a API \u5171\u5b58\u7684\u65f6\u5019\uff0c\u4e00\u4e2a\u6bd4\u8f83\u7b80\u5355\u7684\u529e\u6cd5\u662f\u5728 API \u8bbe\u8ba1\u7684\u65f6\u5019\uff0c\u52a0\u4e0a\u7248\u672c\u53f7\uff0c\u4f8b\u5982&nbsp;\/v1\/xxx&nbsp;\u6216\u8005&nbsp;\/v2\/xxx\uff0c\u4e0d\u8fc7\u8fd9\u79cd\u5199\u6cd5\u6709\u4e00\u4e2a\u5c0f\u5c0f\u7684\u7f3a\u9677\uff0c\u5c31\u662f\u8def\u5f84\u4e2d\u52a0\u4e86\u7248\u672c\u53f7\u4e4b\u540e\uff0c\u8fd9\u4e2a\u8def\u5f84\u770b\u8d77\u6765\u5c31\u4e0d\u662f\u4e00\u4e2a\u5b8c\u7f8e\u7684 REST \u8def\u5f84\u4e86\u3002<\/p>\n<p style=\"text-align: justify\">\u6240\u4ee5\u8fd9\u5757\u8fd8\u6709\u4e00\u4e2a\u65b9\u6848\uff0c\u5c31\u662f\u628a\u8bf7\u6c42\u7684 API \u7684\u7248\u672c\u53f7\u5199\u5230\u8bf7\u6c42\u5934\u4e2d\u3002<\/p>\n<p style=\"text-align: justify\">\u5177\u4f53\u7684\u5b9e\u73b0\u601d\u8def\u662f\u8fd9\u6837\uff1a<\/p>\n<p style=\"text-align: justify\">\u9996\u5148\uff0c\u5728\u5fae\u670d\u52a1\u4e2d\uff0c\u6211\u4eec\u6240\u6709\u7684\u8bf7\u6c42\u4e00\u822c\u6765\u8bf4\u90fd\u4f1a\u7ecf\u8fc7\u7f51\u5173\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u7f51\u5173\u4e2d\u63d0\u53d6\u51fa\u8bf7\u6c42\u5934\u7684 Accept \u53c2\u6570\uff0c\u7136\u540e\u6839\u636e Accept \u4e2d\u7684\u8bf7\u6c42\u7248\u672c\u53f7\uff0c\u505a\u4e0d\u540c\u7684\u8bf7\u6c42\u8f6c\u53d1\uff0c\u5982\u679c\u7248\u672c\u53f7\u662f 1.0\uff0c\u5c31\u8f6c\u53d1\u5230 1.0 \u7684\u670d\u52a1\u4e0a\u53bb\uff1b\u5982\u679c\u7248\u672c\u53f7\u662f 2.0\uff0c\u5219\u8f6c\u53d1\u5230 2.0 \u7684\u670d\u52a1\u4e0a\u53bb\u3002\u57fa\u672c\u4e0a\u5c31\u662f\u8fd9\u4e2a\u6837\u5b50\u3002<\/p>\n<p style=\"text-align: justify\">\u4ee5\u73b0\u5728\u5fae\u670d\u52a1\u4e2d\u4e3b\u6d41\u7684\u7f51\u5173 Spring Cloud Gateway \u4e3a\u4f8b\uff0c\u6211\u4eec\u53ef\u4ee5\u505a\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<pre>spring<span>:<\/span><br>  application<span>:<\/span><br>    name<span>:<\/span> gateway<br>  cloud<span>:<\/span><br>    nacos<span>:<\/span><br>      discovery<span>:<\/span><br>        password<span>:<\/span> nacos<br>        username<span>:<\/span> nacos<br>        server<span style=\"color: #d73a49\">-<\/span>addr<span>:<\/span> a<span style=\"color: #005cc5\">.b<\/span><span style=\"color: #005cc5\">.c<\/span><span style=\"color: #005cc5\">.d<\/span><span>:<\/span><span style=\"color: #005cc5\">8848<\/span><br>        namespace<span>:<\/span> public<br>    gateway<span>:<\/span><br>      discovery<span>:<\/span><br>        locator<span>:<\/span><br>#          enabled<span>:<\/span> <span style=\"color: #905\">true<\/span><br>          lower<span style=\"color: #d73a49\">-<\/span>case<span style=\"color: #d73a49\">-<\/span>service<span style=\"color: #d73a49\">-<\/span>id<span>:<\/span> <span style=\"color: #905\">true<\/span><br>      routes<span>:<\/span><br>        <span style=\"color: #d73a49\">-<\/span> id<span>:<\/span> v1_provider<br>          uri<span>:<\/span> lb<span>:<\/span><span style=\"color: #d73a49\">\/\/<\/span>provider<br>          predicates<span>:<\/span><br>            <span style=\"color: #d73a49\">-<\/span> Path<span style=\"color: #d73a49\">=\/<\/span>p<span style=\"color: #6a737d\">\/**<\/span><br><span style=\"color: #6a737d\">            - Header=Accept,.*;?version=1\\.0(|;.*)<\/span><br><span style=\"color: #6a737d\">          filters:<\/span><br><span style=\"color: #6a737d\">            - StripPrefix=1<\/span><br><span style=\"color: #6a737d\">server:<\/span><br><span style=\"color: #6a737d\">  port: 8082<\/span><\/pre>\n<\/p>\n<p style=\"text-align: justify\">\u5927\u5bb6\u770b\u4e00\u4e0b\u8fd9\u4e2a\u914d\u7f6e\uff1a<\/p>\n<p style=\"text-align: justify\">\u9996\u5148\u8bb0\u5f97\u5173\u95ed\u670d\u52a1\u81ea\u52a8\u53d1\u73b0\uff0c\u5426\u5219\u901a\u8fc7\u9ed8\u8ba4\u7684\u670d\u52a1\u540d\u8fdb\u884c\u4ee3\u7406\u5c31\u4e0d\u4f1a\u7ecf\u8fc7\u6211\u4eec\u914d\u7f6e\u7684\u8fc7\u6ee4\u5668\u4e86\u3002<\/p>\n<p style=\"text-align: justify\">\u7136\u540e\u6211\u4eec\u624b\u52a8\u914d\u7f6e\u670d\u52a1\u8f6c\u53d1\uff0c\u4e0a\u9762\u7684\u914d\u7f6e\u57fa\u672c\u4e0a\u90fd\u662f\u5e38\u89c4\u914d\u7f6e\uff0c\u8ddf\u7248\u672c\u53f7\u76f8\u5173\u7684\u914d\u7f6e\u662f&nbsp;Header=Accept,.*;?version=1\\.0(|;.*)\uff0c\u8fd9\u4e2a\u914d\u7f6e\u5c31\u662f\u5bf9\u8bf7\u6c42\u5934\u63d0\u51fa\u8981\u6c42\uff0c\u9996\u5148\u524d\u9762\u7684 Accept \u8868\u793a\u8fd9\u91cc\u662f\u8981\u5224\u65ad\u8bf7\u6c42\u5934\u4e2d\u7684 Accept \u5b57\u6bb5\uff0c\u7136\u540e\u540e\u9762\u7d27\u8ddf\u7740\u7684\u662f value\uff08\u4e24\u8005\u4e4b\u95f4\u7528 , \u9694\u5f00\uff09\uff0c\u8fd9\u4e2a value \u662f\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f&nbsp;.*;?version=1\\.0(|;.*)\uff0c\u610f\u601d\u5c31\u662f\u5728&nbsp;version=1.0&nbsp;\u4e4b\u524d\u548c\u4e4b\u540e\u53ef\u4ee5\u6709\u4efb\u610f\u5b57\u7b26\u4e32\uff0c\u53ea\u8981 value \u4e2d\u5305\u542b&nbsp;version=1.0&nbsp;\u5c31\u7b97\u5339\u914d\u4e0a\u4e86\u3002\u53ea\u6709\u5339\u914d\u4e0a\u4e86\uff0c\u624d\u4f1a\u8fdb\u884c\u8bf7\u6c42\u8f6c\u53d1\uff0c\u5426\u5219\u4e0d\u4f1a\u8fdb\u884c\u8bf7\u6c42\u8f6c\u53d1\u3002<\/p>\n<p style=\"text-align: justify\">\u6700\u540e\uff0c\u6211\u4eec\u5728\u53d1\u9001\u8bf7\u6c42\u7684\u65f6\u5019\uff0c\u8bbe\u7f6e\u5982\u4e0b\u8bf7\u6c42\u5934\u5373\u53ef\uff1a<\/p>\n<p style=\"text-align:center\">\n<p style=\"text-align: justify\">\u5982\u679c\u7248\u672c\u53f7\u662f&nbsp;\u200bversinotallow=2.0\u200b\uff0c\u5219\u4f1a\u62a5\u4e00\u4e2a 404 \u9519\u8bef\uff1a<\/p>\n<p style=\"text-align:center\">\n<p style=\"text-align: justify\">\u597d\u5566\uff0c\u4e00\u4e2a\u5c0f\u5c0f\u7684\u7248\u672c\u53f7\u8bdd\u9898\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u8bd5\u8bd5\u6700\u540e\u8fd9\u6bb5\u4ee3\u7801\u54e6\uff5e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u6765\u804a\u4e00\u4e0b\u5fae\u670d\u52a1\u9879\u76ee\u4e2d\u7684\u7248\u672c\u53f7\u8981\u600e\u4e48\u8bbe\u8ba1\u3002 \u5c0f\u4f19\u4f34\u4eec\u5e73\u65f6\u770b\u5230\u7684\u9879\u76ee\u7248\u672c\u53f7\uff0c\u57fa\u672c\u4e0a\u90fd\u662f\u5206\u4e3a\u4e86\u4e09\u90e8\u5206&#038;nbs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":329279,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-329278","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/329278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=329278"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/329278\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/329279"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=329278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=329278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=329278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}