{"id":2057,"date":"2024-06-13T00:10:56","date_gmt":"2024-06-12T16:10:56","guid":{"rendered":"https:\/\/zhuxinyong.com\/?p=2057"},"modified":"2024-06-19T11:13:48","modified_gmt":"2024-06-19T03:13:48","slug":"ts-index-signatures","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=2057","title":{"rendered":"TS &#8211; Index Signatures"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2024\/06\/17182088865289.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u4f60\u6709 2 \u4e2a\u63cf\u8ff0\uff0c\u8f6f\u4ef6\u5f00\u53d1\u4eba\u5458\u85aa\u6c34\u7684\u5bf9\u8c61\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const salary1 = {  \n\n    baseSalary: 100_000,  \n    \n    yearlyBonus: 20_000  \n\n};  \n\n  \n\nconst salary2 = {  \n\n    contractSalary: 110_000  \n\n};\n<\/code><\/pre>\n\n\n\n<p>\u60a8\u60f3\u5b9e\u73b0\u4e00\u4e2a\u6839\u636e\u5de5\u8d44\u5bf9\u8c61\u8fd4\u56de\u603b\u85aa\u916c\u7684\u51fd\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">function totalSalary(salaryObject: ???) {  \n\n\tlet total = 0;  \n\t\n\tfor (const name in salaryObject) {  \n\t\n\t\ttotal += salaryObject[name];  \n\t\n\t}  \n\t\n\treturn total;  \n\n}  \n\nconsole.log(totalSalary(salary1)); \/\/ =&gt; 120_000  \n\nconsole.log(totalSalary(salary2)); \/\/ =&gt; 110_000\n<\/code><\/pre>\n\n\n\n<p>\u60a8\u5c06\u5982\u4f55\u6ce8\u91ca<code>totalSalary()<\/code>\u51fd\u6570\u7684<code>salaryObject<\/code>\u53c2\u6570\u4ee5\u63a5\u53d7\u952e\u4e3a\u5b57\u7b26\u4e32\u3001\u503c\u4e3a\u6570\u5b57\u7684\u5bf9\u8c61\uff1f<\/p>\n\n\n\n<p>\u7b54\u6848\u662f\u4f7f\u7528\u7d22\u5f15\u7b7e\u540d\uff01<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u627e\u5230\u4ec0\u4e48\u662fTypeScript\u7d22\u5f15\u7b7e\u540d\u4ee5\u53ca\u4f55\u65f6\u9700\u8981\u5b83\u4eec\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"1%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E7%B4%A2%E5%BC%95%E7%AD%BE%E5%90%8D\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>1.\u4e3a\u4ec0\u4e48\u8981\u7d22\u5f15\u7b7e\u540d<\/h2>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u7684\u601d\u60f3\u662f\u5728\u60a8\u53ea\u77e5\u9053\u952e\u548c\u503c\u7c7b\u578b\u65f6\u952e\u5165\u672a\u77e5\u7ed3\u6784\u7684\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u9002\u5408\u85aa\u6c34\u53c2\u6570\u7684\u60c5\u51b5\uff1a\u8be5\u51fd\u6570\u5e94\u8be5\u63a5\u53d7\u4e0d\u540c\u7ed3\u6784\u7684\u85aa\u6c34\u5bf9\u8c61-\u53ea\u9700\u786e\u4fdd\u5bf9\u8c61\u503c\u662f\u6570\u5b57\u3002<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u7528\u7d22\u5f15\u7b7e\u540d\u6ce8\u91ca<code>salaryObject<\/code>\u53c2\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">function totalSalary(salaryObject: { [key: string]: number }) {  \n\n\tlet total = 0;  \n\t\n\tfor (const name in salaryObject) {  \n\t\n\t\ttotal += salaryObject[name];  \n\t\n\t}  \n\t\n\treturn total;  \n\n}  \n\n  \n\nconsole.log(totalSalary(salary1)); \/\/ =&gt; 120_000  \n\nconsole.log(totalSalary(salary2)); \/\/ =&gt; 110_000\n<\/code><\/pre>\n\n\n\n<p><code>{ [key: string]: number }<\/code>\u662f\u7d22\u5f15\u7b7e\u540d\uff0c\u5b83\u544a\u8bc9TypeScript<code>salaryObject<\/code>\u5fc5\u987b\u662f\u4e00\u4e2a\u4ee5<code>string<\/code>type\u4f5c\u4e3a\u952e\u548c<code>number<\/code>type\u4f5c\u4e3a\u503c\u7684\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u73b0\u5728<code>totalSalary()<\/code>\u63a5\u53d7<code>salary1<\/code>\u548c<code>salary2<\/code>\u5bf9\u8c61\u4f5c\u4e3a\u53c2\u6570\uff0c\u56e0\u4e3a\u5b83\u4eec\u662f\u5177\u6709\u6570\u5b57\u503c\u7684\u5bf9\u8c61\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\uff0c\u8be5\u51fd\u6570\u4e0d\u4f1a\u63a5\u53d7\u5177\u6709\u4f8b\u5982\u5b57\u7b26\u4e32\u4f5c\u4e3a\u503c\u7684\u5bf9\u8c61\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const salary3 = {  \n\n\tbaseSalary: '100 thousands'  \n\n};  \n\n  \n\n\/\/ Type error:  \n\n\/\/ Argument of type '{ baseSalary: string; }' is not assignable to parameter of type '{ [key: string]: number; }'.  \n\n\/\/ Property 'baseSalary' is incompatible with index signature.  \n\n\/\/ Type 'string' is not assignable to type 'number'.  \n\ntotalSalary(salary3);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"2%E7%B4%A2%E5%BC%95%E7%AD%BE%E5%90%8D%E8%AF%AD%E6%B3%95\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>2.\u7d22\u5f15\u7b7e\u540d\u8bed\u6cd5<\/h2>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u7684\u8bed\u6cd5\u5f88\u7b80\u5355\uff0c\u770b\u8d77\u6765\u7c7b\u4f3c\u4e8e\u5c5e\u6027\u7684\u8bed\u6cd5\u3002\u4f46\u6709\u4e00\u4e2a\u533a\u522b\uff1a\u5c06\u952e\u7684\u7c7b\u578b\u5199\u5728\u65b9\u62ec\u53f7\u5185\uff1a<code>{ [key: KeyType]: ValueType }<\/code>\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u7d22\u5f15\u7b7e\u540d\u7684\u51e0\u4e2a\u793a\u4f8b\u3002<\/p>\n\n\n\n<p><code>string<\/code>type\u662f\u952e\u548c\u503c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface StringByString {  \n\n\t[key: string]: string;  \n\n}  \n\n  \n\nconst heroesInBooks: StringByString = {  \n\n\t'Gunslinger': 'The Dark Tower',  \n\t\n\t'Jack Torrance': 'The Shining'  \n\n};\n<\/code><\/pre>\n\n\n\n<p><code>string<\/code>\u7c7b\u578b\u662f\u952e\uff0c\u503c\u53ef\u4ee5\u662f<code>string<\/code>\u3001<code>number<\/code>\u6216<code>boolean<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface Options {  \n\n\t[key: string]: string | number | boolean;  \n\t\n\ttimeout: number;  \n\n}  \n\n  \n\nconst options: Options = {  \n\n\ttimeout: 1000,  \n\t\n\ttimeoutMessage: 'The request timed out!',  \n\t\n\tisFileUpload: false  \n\n};\n<\/code><\/pre>\n\n\n\n<p><code>Options<\/code>\u63a5\u53e3\u8fd8\u6709\u4e00\u4e2a\u5b57\u6bb5<code>timeout<\/code>\uff0c\u5b83\u5728\u7d22\u5f15\u7b7e\u540d\u9644\u8fd1\u5de5\u4f5c\u6b63\u5e38\u3002<\/p>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u7684\u952e\u53ea\u80fd\u662f<code>string<\/code>\u3001<code>number<\/code>\u6216<code>symbol<\/code>\u3002\u4e0d\u5141\u8bb8\u5176\u4ed6\u7c7b\u578b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface OopsDictionary {  \n\n\/\/ Type error:  \n\n\/\/ An index signature parameter type must be 'string', 'number',  \n\n\/\/ 'symbol', or a template literal type.  \n\n\t[key: boolean]: string;  \n\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"3%E7%B4%A2%E5%BC%95%E7%AD%BE%E5%90%8D%E8%AD%A6%E5%91%8A\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>3.\u7d22\u5f15\u7b7e\u540d\u8b66\u544a<\/h2>\n\n\n\n<p>TypeScript\u4e2d\u7684\u7d22\u5f15\u7b7e\u540d\u6709\u4e00\u4e9b\u60a8\u5e94\u8be5\u6ce8\u610f\u7684\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"3-1%E4%B8%8D%E5%AD%98%E5%9C%A8%E7%9A%84%E8%B4%A2%E4%BA%A7\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>3.1\u4e0d\u5b58\u5728\u7684\u8d22\u4ea7<\/h3>\n\n\n\n<p>\u5982\u679c\u60a8\u5c1d\u8bd5\u8bbf\u95ee\u7d22\u5f15\u7b7e\u540d\u4e3a<code>{ [key: string]: string }<\/code>\u7684\u5bf9\u8c61\u7684\u4e0d\u5b58\u5728\u5c5e\u6027\u4f1a\u53d1\u751f\u4ec0\u4e48\uff1f<\/p>\n\n\n\n<p>\u6b63\u5982\u9884\u671f\u7684\u90a3\u6837\uff0cTypeScript\u5c06\u503c\u7684\u7c7b\u578b\u63a8\u65ad\u4e3a<code>string<\/code>\u3002\u4f46\u662f\u5982\u679c\u60a8\u68c0\u67e5\u8fd0\u884c\u65f6\u503c-\u5b83\u662f<code>undefined<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface StringByString {  \n\n\t[key: string]: string;  \n\n}  \n\n  \n\nconst object: StringByString = {};  \n\n  \n\nconst value = object['nonExistingProp'];  \n\nconsole.log(value); \/\/ =&gt; undefined\n<\/code><\/pre>\n\n\n\n<p><code>value<\/code>\u6839\u636eTypeScript\uff0c\u53d8\u91cf\u662f<code>string<\/code>\u7c7b\u578b\uff0c\u4f46\u662f\uff0c\u5b83\u7684\u8fd0\u884c\u65f6\u503c\u662f<code>undefined<\/code>\u3002<\/p>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u5c06\u952e\u7c7b\u578b\u6620\u5c04\u5230\u503c\u7c7b\u578b-\u4ec5\u6b64\u800c\u5df2\u3002\u5982\u679c\u60a8\u4e0d\u6b63\u786e\u6620\u5c04\uff0c\u503c\u7c7b\u578b\u53ef\u80fd\u4f1a\u504f\u79bb\u5b9e\u9645\u7684\u8fd0\u884c\u65f6\u6570\u636e\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u4f7f\u952e\u5165\u66f4\u51c6\u786e\uff0c\u8bf7\u5c06\u7d22\u5f15\u503c\u6807\u8bb0\u4e3a<code>string<\/code>\u6216<code>undefined<\/code>\u3002\u8fd9\u6837\u505a\uff0cTypeScript\u4f1a\u610f\u8bc6\u5230\u60a8\u8bbf\u95ee\u7684\u5c5e\u6027\u53ef\u80fd\u4e0d\u5b58\u5728\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface StringByString {  \n\n\t[key: string]: string | undefined;  \n\n}  \n\n  \n\nconst object: StringByString = {};  \n\n  \n\nconst value = object['nonExistingProp'];  \n\nconsole.log(value); \/\/ =&gt; undefined\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a id=\"3-2%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E6%95%B0%E5%AD%97%E9%94%AE\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>3.2\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u952e<\/h3>\n\n\n\n<p>\u5047\u8bbe\u60a8\u6709\u4e00\u672c\u6570\u5b57\u540d\u79f0\u5b57\u5178\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface NumbersNames {  \n\n\t[key: string]: string  \n\n}  \n\n  \n\nconst names: NumbersNames = {  \n\n\t'1': 'one',  \n\t\n\t'2': 'two',  \n\t\n\t'3': 'three',  \n\t\n\t\/\/ etc...  \n\n};\n<\/code><\/pre>\n\n\n\n<p>\u901a\u8fc7\u5b57\u7b26\u4e32\u952e\u8bbf\u95ee\u503c\u6309\u9884\u671f\u5de5\u4f5c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const value1 = names['1']; \/\/ OK\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u60a8\u901a\u8fc7\u6570\u5b57<code>1<\/code>\u8bbf\u95ee\u503c\u4f1a\u51fa\u9519\u5417\uff1f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const value2 = names[1]; \/\/ OK  \n<\/code><\/pre>\n\n\n\n<p>\u6ca1\u6709\uff0c\u90fd\u5f88\u597d\uff01<\/p>\n\n\n\n<p>\u5f53\u5728\u5c5e\u6027\u8bbf\u95ee\u5668\u4e2d\u7528\u4f5c\u952e\u65f6\uff0cJavaScript\u4f1a\u5c06\u6570\u5b57\u9690\u5f0f\u5f3a\u5236\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff08<code>names[1]<\/code>\u4e0e<code>names['1']<\/code>\u76f8\u540c\uff09\u3002TypeScript\u4e5f\u6267\u884c\u8fd9\u79cd\u5f3a\u5236\u3002<\/p>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u8ba4\u4e3a<code>[key: string]<\/code>\u4e0e<code>[key: string | number]<\/code>\u76f8\u540c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"4%E7%B4%A2%E5%BC%95%E7%AD%BE%E5%90%8D%E4%B8%8E%E8%AE%B0%E5%BD%95\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>4.\u7d22\u5f15\u7b7e\u540d\u4e0e\u8bb0\u5f55<\/h2>\n\n\n\n<p>TypeScript\u6709\u4e00\u4e2a<a class=\"copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/utility-types.html#recordkeys-type\" target=\"_blank\" rel=\"noopener\">\u5b9e\u7528\u7a0b\u5e8f\u7c7b\u578b<\/a><code>Record&lt;Keys, Values&gt;<\/code>\u6765\u6ce8\u91ca\u8bb0\u5f55\uff0c\u7c7b\u4f3c\u4e8e\u7d22\u5f15\u7b7e\u540d\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">const object1: Record&lt;string, string&gt; = { prop: 'Value' }; \/\/ OK  \n\nconst object2: { [key: string]: string } = { prop: 'Value' }; \/\/ OK\n<\/code><\/pre>\n\n\n\n<p>\u6700\u5927\u7684\u95ee\u9898\u662f\u2026\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528<code>Record&lt;Keys, Values&gt;<\/code>\u4ee5\u53ca\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528\u7d22\u5f15\u7b7e\u540d\uff1f\u4e4d\u4e00\u770b\uff0c\u5b83\u4eec\u770b\u8d77\u6765\u5f88\u76f8\u4f3c\uff01<\/p>\n\n\n\n<p>\u5982\u60a8\u4e4b\u524d\u6240\u89c1\uff0c\u7d22\u5f15\u7b7e\u540d\u4ec5\u63a5\u53d7<code>string<\/code>\u3001<code>number<\/code>\u6216<code>symbol<\/code>\u4f5c\u4e3a\u5bc6\u94a5\u7c7b\u578b\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5c1d\u8bd5\u4f7f\u7528\u5b57\u7b26\u4e32\u6587\u5b57\u7c7b\u578b\u7684\u5e76\u96c6\u4f5c\u4e3a\u7d22\u5f15\u7b7e\u540d\u4e2d\u7684\u952e\uff0c\u5219\u4f1a\u51fa\u9519\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">interface Salary {  \n\n\/\/ Type error:  \n\n\/\/ An index signature parameter type cannot be a literal type or generic type.  \n\n\/\/ Consider using a mapped object type instead.  \n\n\t[key: 'yearlySalary' | 'yearlyBonus']: number  \n\n}\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u79cd\u884c\u4e3a\u8868\u660e_\u7d22\u5f15\u7b7e\u540d\u5728\u952e\u65b9\u9762\u662f\u901a\u7528\u7684\u3002_<\/p>\n\n\n\n<p>\u4f46\u662f\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u6587\u5b57\u7684\u5e76\u96c6\u6765\u63cf\u8ff0<code>Record&lt;Keys, Values&gt;<\/code>\u4e2d\u7684\u952e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"typescript\" class=\"language-typescript\">type SpecificSalary = Record&lt;'yearlySalary'|'yearlyBonus', number&gt;  \n\ntype GenericSalary = Record&lt;string, number&gt;  \n\n  \n\nconst salary1: SpecificSalary = {  \n\n\t'yearlySalary': 120_000,  \n\t\n\t'yearlyBonus': 10_000  \n\n}; \/\/ OK\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u60a8\u60f3\u5c06\u952e\u9650\u5236\u4e3a\u7279\u5b9a\u5b57\u7b26\u4e32\u7684\u5e76\u96c6\uff0c\u5219<code>Record&lt;'prop1' | 'prop2' | ... | 'propN', Values&gt;<\/code>\u662f\u66ff\u4ee3\u7d22\u5f15\u7b7e\u540d\u7684\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a id=\"5%E7%BB%93%E8%AE%BA\" class=\"anchor copySomeTextFromLink\" style=\"user-select: text;\" draggable=\"false\" aria-hidden=\"true\"><\/a>5.\u7ed3\u8bba<\/h2>\n\n\n\n<p>\u5f53\u60a8\u4e0d\u77e5\u9053\u5bf9\u8c61\u7684\u786e\u5207\u7ed3\u6784\uff0c\u4f46\u60a8\u77e5\u9053\u952e\u548c\u503c\u7c7b\u578b\u65f6\uff0c\u7d22\u5f15\u7b7e\u540d\u6ce8\u91ca\u975e\u5e38\u9002\u5408\u8fd9\u79cd\u60c5\u51b5\u3002<\/p>\n\n\n\n<p>\u7d22\u5f15\u7b7e\u540d\u7531\u65b9\u62ec\u53f7\u4e2d\u7684\u7d22\u5f15\u540d\u79f0\u53ca\u5176\u7c7b\u578b\u7ec4\u6210\uff0c\u540e\u8ddf\u5192\u53f7\u548c\u503c\u7c7b\u578b\uff1a<code>{ [indexName: Keys]: Values }<\/code>\u3002<code>Keys<\/code>\u53ef\u4ee5\u662f<code>string<\/code>\u3001<code>number<\/code>\u6216<code>symbol<\/code>\uff0c\u800c<code>Values<\/code>\u53ef\u4ee5\u662f\u4efb\u4f55\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u8981\u5c06\u952e\u7c7b\u578b\u9650\u5236\u4e3a\u7279\u5b9a\u7684\u5b57\u7b26\u4e32\u5e76\u96c6\uff0c\u5219\u4f7f\u7528<code>Record&lt;Keys, Values&gt;<\/code>utilty\u7c7b\u578b\u662f\u4e00\u4e2a\u66f4\u597d\u7684\u4e3b\u610f\u3002\u7d22\u5f15\u7b7e\u540d\u4e0d\u652f\u6301\u5b57\u7b26\u4e32\u6587\u5b57\u7c7b\u578b\u7684\u5e76\u96c6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u6709 2 \u4e2a\u63cf\u8ff0\uff0c\u8f6f\u4ef6\u5f00\u53d1\u4eba\u5458\u85aa\u6c34\u7684\u5bf9\u8c61\uff1a \u60a8\u60f3\u5b9e\u73b0\u4e00\u4e2a\u6839\u636e\u5de5\u8d44\u5bf9\u8c61\u8fd4\u56de\u603b\u85aa\u916c\u7684\u51fd\u6570\uff1a \u60a8\u5c06\u5982\u4f55\u6ce8\u91ca&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,20,3],"tags":[33],"class_list":["post-2057","post","type-post","status-publish","format-standard","hentry","category-all","category-frontend","category-tech","tag-typescript"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/2057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2057"}],"version-history":[{"count":4,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/2057\/revisions"}],"predecessor-version":[{"id":2063,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/2057\/revisions\/2063"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}