{"id":1473,"date":"2022-08-08T23:34:45","date_gmt":"2022-08-08T15:34:45","guid":{"rendered":"https:\/\/zhuxinyong.com\/?p=1473"},"modified":"2022-08-11T22:50:09","modified_gmt":"2022-08-11T14:50:09","slug":"she-ji-mo-shi-javascript-zhong-de-mo-ban-fang-fa","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=1473","title":{"rendered":"\u8bbe\u8ba1\u6a21\u5f0f &#8211; JavaScript \u4e2d\u7684\u6a21\u7248\u65b9\u6cd5\u6a21\u5f0f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16600563503031.jpg\" alt=\"\" \/><\/p>\n<p>\u539f\u6587\u5730\u5740\uff1a<a href=\"https:\/\/dev.to\/carlillo\/design-patterns---template-method-180k\" target=\"_blank\" rel=\"noopener\">https:\/\/dev.to\/carlillo\/design-patterns&#8212;template-method-180k<\/a><\/p>\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u4f1a\u4ecb\u7ecd\u4ec0\u4e48\u662f\u6a21\u7248\u65b9\u6cd5\u6a21\u5f0f\uff0c\u4ee5\u53ca\u5982\u4f55\u548c\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528\u5b83\u3002<\/p>\n<h2><a id=\"%E6%A8%A1%E7%89%88%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F%EF%BC%9A%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u6a21\u7248\u65b9\u6cd5\u6a21\u5f0f\uff1a\u57fa\u7840\u6982\u5ff5<\/h2>\n<blockquote>\n<p>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u662f\u4e00\u79cd\u884c\u4e3a\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5b83\u5b9a\u4e49\u4e86\u4e00\u4e2a\u64cd\u4f5c\u4e2d\u7b97\u6cd5\u7684\u9aa8\u67b6\uff0c\u5c06\u4e00\u4e9b\u6b65\u9aa4\u63a8\u8fdf\u5230\u5b50\u7c7b\u4e2d\u3002 &#8211;Wikipedia<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u5728\u4e00\u4e2a\u64cd\u4f5c\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u7b97\u6cd5\u7684\u9aa8\u67b6\uff0c\u63a8\u8fdf\u4e00\u4e9b\u6b65\u9aa4\u5230\u5b50\u7c7b\u4e2d\u3002\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u4f7f\u5b50\u7c7b\u53ef\u4ee5\u5728\u4e0d\u66f4\u6539\u7b97\u6cd5\u7ed3\u6784\u7684\u60c5\u51b5\u4e0b\u91cd\u65b0\u5b9a\u4e49\u7b97\u6cd5\u7684\u4e00\u4e9b\u6b65\u9aa4\u3002 &#8212; Design Patterns: Elements of Reusable Object-Oriented Software<\/p>\n<\/blockquote>\n<blockquote>\n<p>\u8fd9\u79cd\u6a21\u5f0f\u7684\u4e3b\u8981\u7279\u70b9\u662f\u5728\u4e0d\u540c\u7c7b\u578b\u7684\u7c7b\u4e2d\u7b97\u6cd5\u7a0d\u6709\u4e0d\u540c\u3002\u5f53\u5b9e\u73b0\u5177\u4f53\u7c7b\u65f6\uff0c\u8fd9\u4e9b\u5171\u540c\u7684\u90e8\u5206\u5728\u4e0d\u540c\u7684\u7b97\u6cd5\u4e2d\u91cd\u590d\u3002<\/p>\n<\/blockquote>\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u6f14\u793a\u4e86\u4e00\u4e2a\u7ecf\u5178\u95ee\u9898\uff0c\u5c31\u662f\u4f60\u5fc5\u987b\u91cd\u590d\u4e00\u90e8\u5206\u7a0d\u6709\u4e0d\u540c\u7684\u7b97\u6cd5\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16600578086754.jpg\" alt=\"\" \/><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 <strong>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f<\/strong> \u4f7f\u4ee3\u7801\u66f4\u7b80\u6d01\uff0c\u4f7f\u5f97\u6211\u4eec\u907f\u514d\u5728\u7b97\u6cd5\u7684\u4e0d\u540c\u5b9e\u73b0\u4e2d\u91cd\u590d\u4ee3\u7801\u3002\u5b83\u7684 UML \u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16600563503031.jpg\" alt=\"\" \/><\/p>\n<p>\u6ce8\u610f\u8fd9\u4e2a\u62bd\u8c61\u7c7b\uff0c\u5305\u542b\u6a21\u677f\u65b9\u6cd5\u548c\u5171\u540c\u7684\u79c1\u6709\u65b9\u6cd5\u3002\u6a21\u677f\u65b9\u6cd5\u63cf\u8ff0\u4e86\u4e0d\u540c\u6b65\u9aa4\u7684\u7b97\u6cd5\u3002\u5171\u540c\u7684\u6b65\u9aa4\u5728\u62bd\u8c61\u7c7b\u4e2d\u5b9e\u73b0\uff0c\u800c\u5177\u4f53\u7684\u6b65\u9aa4\u5728\u6bcf\u4e2a\u5177\u4f53\u7c7b\u4e2d\u662f\u4e0d\u540c\u7684\uff0c\u5b83\u4eec\u5728\u4e0a\u8ff0\u7684\u5177\u4f53\u7c7b\u4e2d\u5b9e\u73b0\u3002<\/p>\n<h2><a id=\"%E6%A8%A1%E6%9D%BF%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F%EF%BC%9A%E4%BB%80%E4%B9%88%E6%97%B6%E5%80%99%E4%BD%BF%E7%94%A8\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\uff1a\u4ec0\u4e48\u65f6\u5019\u4f7f\u7528<\/h2>\n<ul>\n<li>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u89e3\u51b3\u7684\u95ee\u9898\u662f\uff1a\u4f7f\u7528\u7684\u7b97\u6cd5\u6709\u4e9b\u8bb8\u4e0d\u540c\uff0c\u4f60\u9700\u8981\u628a\u4f60\u7684\u7b97\u6cd5\u5206\u6210\u4e0d\u540c\u7684\u6b65\u9aa4\uff0c\u5728\u4e0d\u540c\u7684\u5b9e\u73b0\u4e4b\u95f4\u6709\u5171\u540c\u70b9\u7684\u65f6\u5019\u5728\u62bd\u8c61\u7c7b\u4e2d\u5b9e\u73b0\u3002\u53e6\u4e00\u65b9\u9762\uff0c\u4e0d\u540c\u7684\u6b65\u9aa4\u5c06\u4f1a\u5728\u5177\u4f53\u7684\u7c7b\u4e2d\u5b9e\u73b0\u3002<\/li>\n<li>\u53e6\u4e00\u4e2a\u6709\u8da3\u7684\u573a\u666f\u662f\u5f53\u4f60\u5728\u4e0d\u540c\u7684\u7c7b\u4e4b\u95f4\u62f7\u8d1d\/\u7c98\u8d34\u4ee3\u7801\u65f6\uff0c\u4f1a\u610f\u8bc6\u5230\u4f7f\u7528\u6b64\u6a21\u5f0f\u3002<\/li>\n<li>\u6700\u540e\uff0c\u5f53\u4f60\u7684\u591a\u6570\u7c7b\u6709\u76f8\u540c\u7684\u884c\u4e3a\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8be5\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<h2><a id=\"%E6%A8%A1%E6%9D%BF%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F%EF%BC%9A%E4%BC%98%E5%8A%BF\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\uff1a\u4f18\u52bf<\/h2>\n<p>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u6709\u8bb8\u591a\u4f18\u52bf\uff0c\u603b\u7ed3\u4e3a\u5982\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>\u56e0\u4e3a\u4f60\u4f7f\u7528\u62bd\u8c61\u7c7b\u628a\u8be5\u7c7b\u95ee\u9898\u7684\u516c\u5171\u4ee3\u7801\u79fb\u9664\u4e86\uff0c\u6240\u4ee5\u521b\u5efa\u5177\u4f53\u7684\u7b97\u6cd5\u5b9e\u73b0\u5f88\u7b80\u5355\u3002<\/li>\n<li>\u56e0\u4e3a\u4f60\u907f\u514d\u4e86\u91cd\u590d\u4ee3\u7801\uff0c\u6240\u4ee5\u4ee3\u7801\u66f4\u7b80\u6d01\u3002<\/li>\n<li>\u56e0\u4e3a\u4f60\u628a\u7b97\u6cd5\u5206\u5272\u5230\u79c1\u6709\u7684\u65b9\u6cd5\/\u51fd\u6570\u4e2d\u53bb\u4e86\uff0c\u4f7f\u5f97\u6d4b\u53d8\u5f97\u66f4\u7b80\u5355\u548c\u5bb9\u6613\u3002<\/li>\n<\/ul>\n<h2><a id=\"%E6%A8%A1%E6%9D%BF%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F%EF%BC%9A%E4%BD%BF%E7%94%A8javascript%E5%AE%9E%E7%8E%B0%E4%B8%80%E4%B8%AA%E5%8F%A3%E8%A2%8B%E7%B2%BE%E7%81%B5\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\uff1a\u4f7f\u7528 JavaScript \u5b9e\u73b0\u4e00\u4e2a\u53e3\u888b\u7cbe\u7075<\/h2>\n<p>\u73b0\u5728\u6211\u5c06\u7ed9\u4f60\u6f14\u793a\u4f7f\u7528 JavaScript \u5982\u4f55\u5b9e\u73b0\u8fd9\u79cd\u6a21\u5f0f\u3002\u8bf7\u8bb0\u4f4f JavaScript \u7f3a\u4e4f\u63a5\u53e3\u548c\u62bd\u8c61\u7c7b\u3002\u56e0\u6b64\uff0c\u7406\u89e3\u6b64\u6a21\u5f0f\u6700\u597d\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u4f8b\u5b50\u3002\u5728\u6211\u4eec\u7684\u4f8b\u5b50\u4e2d\uff0c\u6211\u8bbe\u60f3\u4e86\u4e00\u95ee\u9898\uff0c\u5c31\u662f\u6709\u4e00\u4e2a\u540d\u4e3a <code>Pokemon<\/code> \u7684\u62bd\u8c61\u7c7b\u6765\u5b9e\u4f8b\u5316 Pokemon\u3002\u4e00\u4e2a pokemon \u6709\u4e00\u7ec4\u5c5e\u6027 <code>name<\/code> \u3001 <code>power<\/code> \u3001<code>attack<\/code> \u548c <code>defense<\/code>\uff0c\u9664\u6b64\u4e4b\u5916\u8fd8\u6709\u7ecf\u5178\u7684 <code>toString<\/code> \u65b9\u6cd5\u3002pokemon \u6709\u7c7b\u578b\u5206\u7c7b\uff0c\u6bd4\u5982 <code>FightingPokemon<\/code> \u3001<code>PoisonPokemon<\/code> \u548c <code>GroundPokemon<\/code> \u5b83\u4eec\u5404\u81ea\u5b9a\u4e49\u4e86\u4e00\u4e2a\u5177\u4f53\u7684\u65b9\u6cd5 <code>calculateDamage<\/code> \uff0c\u6839\u636e\u5c5e\u6027\u548c pokemon \u7684\u7c7b\u578b\u8ba1\u7b97\u6570\u503c\u3002\u4e0b\u9762\u7684 UML \u56fe\u5c55\u793a\u4e86\u6211\u521a\u63cf\u8ff0\u7684\u573a\u666f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16601405791913.jpg\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16601771294935.jpg\" alt=\"\" \/><\/p>\n<p>\u4f7f\u7528 JavaScript \u4ee3\u7801\u5b9e\u73b0\u771f\u662f\u573a\u666f\u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<p>![](media\/16<img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16601407012291.jpg\" alt=\"\" \/><br \/>\n599728856873\/16601407012291.jpg)<\/p>\n<p><code>calculateDamage<\/code> \u65b9\u6cd5\u91cd\u590d\u51fa\u73b0\u5728\u6bcf\u4e2a\u7c7b\u4e2d\uff0c\u4f8b\u5982\uff1a\u8fd9\u662f\u4e0d\u597d\u7684\u4ee3\u7801\uff08\u590d\u5236\/\u7c98\u8d34&#8211;\u91cd\u590d\u4ee3\u7801\uff09\u3002\u6b64\u65b9\u6cd5\u53ef\u4ee5\u5206\u5272\u4e3a\u4e0d\u540c\u7684\u6b65\u9aa4\uff0c\u5c31\u50cf\u8fd9\u6837\uff1a<\/p>\n<pre><code class=\"language-plain_text\">calculateDamage(){\n  const multipliers = this.calculateMultipliers();\n  const impact = this.calculateImpact(multipliers);\n  const showDamage(impact);\n}\n<\/code><\/pre>\n<p>\u6ce8\u610f\u6211\u4eec\u7684\u65b9\u6cd5\u5df2\u7ecf\u88ab\u5206\u5272\u5230\u4e09\u4e2a\u65b9\u6cd5\u4e2d\u3002\u4e8b\u5b9e\u4e0a\uff0c\u5176\u4e2d\u4e24\u4e2a\u662f\u5171\u7528\u7684\u800c\u53e6\u4e00\u4e2a\u662f\u5177\u4f53\u7684\uff0c\u4f9d\u636e\u7c7b\u6765\u5b9e\u73b0\u5b83\uff08calculateImpact\uff09\u3002\u6211\u4eec\u7684 <code>Template-Method<\/code> \u6a21\u5f0f\u5df2\u7ecf\u4f7f\u7528\u4e0a\u4e86\uff0c\u5728\u4e0b\u9762\u7684 UML \u4e2d\u4f60\u53ef\u4ee5\u770b\u5230\u901a\u8fc7 <code>Template-Method<\/code> \u66f4\u65b0\u7684\u7248\u672c\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16601936539464.jpg\" alt=\"\" \/><\/p>\n<pre><code class=\"language-plain_text\">class Pokemon {\n  constructor(_pokemon) {\n    this.name = _pokemon.name || 'unknown';\n    this.power = _pokemon.power || 1;\n    this.attack = _pokemon.attack || 1;\n    this.defense = _pokemon.defense || 1;\n  }\n  toString() {\n    return `${this.name} -  power: ${this.power}; attack: ${\n      this.attack\n    }; defense: ${this.defense}`;\n  }\n  calculateMultiplier() {\n    \/\/Step 1 - Common\n    return (1 \/ 2) * this.power * Math.random();\n  }\n  showDamage(damage) {\n    \/\/ Step 3 - Common\n    console.log('Pokemon damage is:', damage);\n  }\n  calculateDamage() {\n    const multipliers = this.calculateMultiplier(); \/\/Step 1;\n    const damage = this.calculateImpact(multipliers); \/\/Step 2;\n    this.showDamage(damage); \/\/Step 3;\n  }\n}\n<\/code><\/pre>\n<p>\u4f60\u53ef\u80fd\u5df2\u7ecf\u6ce8\u610f\u5230\u4e86 <code>this.calculateImpact<\/code> \u5e76\u6ca1\u6709\u5728\u8fd9\u4e2a\u7c7b\u4e2d\u5b9e\u73b0\u3002\u8fd9\u662f\u56e0\u4e3a\u5177\u4f53\u7684\u89c6\u7ebf\u5c06\u4f1a\u88ab\u653e\u5230\u5177\u4f53\u7684\u7c7b\u4e2d\u3002\u5728\u6211\u4eec\u8fd9\u4e2a\u95ee\u9898\u4e2d <code>Pokemon<\/code> \u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u7684\u6b65\u9aa4\u7531\u5e26\u6709 <code>calculateImpact<\/code> \u65b9\u6cd5\u7684\u5177\u4f53\u7c7b\u7684\u5b9e\u73b0\u7ec4\u6210\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16601939913141.jpg\" alt=\"\" \/><\/p>\n<pre><code class=\"language-plain_text\">class FightingPokemon extends Pokemon {\n  constructor(_pokemon) {\n    super(_pokemon);\n  }\n  calculateImpact(multipliers) {\n    return Math.floor((this.attack \/ this.defense) * multipliers) + 1;\n  }\n}\n\nclass PoisonPokemon extends Pokemon {\n  constructor(_pokemon) {\n    super(_pokemon);\n  }\n  calculateImpact(multipliers) {\n    return Math.floor((this.attack - this.defense) * multipliers) + 1;\n  }\n}\n\nclass GroundPokemon extends Pokemon {\n  constructor(_pokemon) {\n    super(_pokemon);\n  }\n  calculateImpact(multipliers) {\n    return Math.floor((this.attack + this.defense) * multipliers) + 1;\n  }\n}\n<\/code><\/pre>\n<p>\u6700\u540e\uff0c\u7528\u6237\u7aef\/\u4e0a\u4e0b\u6587\u4f7f\u7528\u6211\u4eec\u7684\u5177\u4f53 Pokemon \u7684\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-plain_text\">\/\/ Client-Context\n\nconst passimian = new FightingPokemon({\n  name: 'Passimian',\n  attack: 10,\n  power: 10,\n  defense: 10\n});\nconsole.log(passimian.toString());\npassimian.calculateDamage();\n\nconst poipole = new PoisonPokemon({\n  name: 'Poipole',\n  attack: 10,\n  power: 10,\n  defense: 10\n});\nconsole.log(poipole.toString());\npoipole.calculateDamage();\n\nconst mudsdale = new GroundPokemon({\n  name: 'Mudsdale',\n  attack: 10,\n  power: 10,\n  defense: 10\n});\nconsole.log(mudsdale.toString());\nmudsdale.calculateDamage();\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u521b\u5efa\u4e86 Pokemon \u7684\u5bf9\u8c61\u4e14\u8c03\u7528\u4e86\u5b83\u81ea\u8eab\u7684\u65b9\u6cd5\uff1a<code>calculateDamage<\/code>\u3002\u5bf9\u4e8e\u7528\u6237\u7aef\/\u4e0a\u4e0b\u6587\u5b83\u7684\u5b9e\u73b0\u662f\u900f\u660e\u7684\uff0c\u4f46\u4ee3\u7801\u5e76\u6ca1\u6709\u91cd\u590d\u3002\u6700\u540e\uff0c\u6211\u521b\u5efa\u4e86\u4e24\u4e2a npm \u811a\u672c\u5206\u522b\u5728\u5e94\u7528 <code>Template-Method<\/code> \u6a21\u5f0f\u524d\u540e\u8fd0\u884c\u4e86\u4e00\u4e0b\u4ee3\u7801\u3002<\/p>\n<pre><code class=\"language-plain_text\">npm run step0\nnpm run step1\n<\/code><\/pre>\n<h2><a id=\"%E6%80%BB%E7%BB%93\" class=\"anchor\" aria-hidden=\"true\"><span class=\"octicon octicon-link\"><\/span><\/a>\u603b\u7ed3<\/h2>\n<p>\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u662f\u4e00\u4e2a\u53ef\u4ee5\u5e2e\u4f60\u5728\u9879\u76ee\u4e2d\u51cf\u5c11\u91cd\u590d\u4ee3\u7801\u7684\u6a21\u5f0f\uff0c\u5f53\u4f60\u4e2a\u7b97\u6cd5\u6709\u4e0d\u53d8\u4e0e\u53d8\u7684\u90e8\u5206\uff0c\u540e\u8005\u4f9d\u8d56\u5177\u4f53\u7684\u7c7b\u3002\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u4f60\u5df2\u7ecf\u770b\u5230\u4e86\u4f7f\u7528\u7f3a\u5c11\u63a5\u53e3\u548c\u62bd\u8c61\u7c7b\u7684 JavaScript \u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u6a21\u677f\u65b9\u6cd5\u6a21\u5f0f\u3002\u5728\u8fd9\u4f8b\u5b50\u4e2d\u4f60\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\u5305\u542b\u63a5\u53e3\u548c\u62bd\u8c61\u7c7b\uff0c\u53ef\u4ee5\u4f9d\u7167 UML \u56fe\u6765\u6a21\u5f0f\u3002<\/p>\n<p>\u6700\u91cd\u8981\u7684\u4e0d\u662f\u6211\u7ed9\u4f60\u6f14\u793a\u7684\u5982\u4f55\u5b9e\u73b0\u6b64\u6a21\u5f0f\uff0c\u800c\u662f\u8ba4\u8bc6\u5230\u8fd9\u4e2a\u6a21\u5f0f\u53ef\u4ee5\u89e3\u51b3\u7684\u95ee\u9898\u3002\u4ee5\u53ca\u4f60\u4ec0\u4e48\u65f6\u5019\u53ef\u4ee5\u6216\u4e0d\u53ef\u4ee5\u5b9e\u73b0\u6240\u8bf4\u7684\u6a21\u5f0f\uff0c\u8fd9\u662f\u81f3\u5173\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u5b9e\u73b0\u6b64\u6a21\u5f0f\u5f88\u4f9d\u8d56\u4f60\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2022\/08\/16602291300888.jpg\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u5730\u5740\uff1ahttps:\/\/dev.to\/carlillo\/design-patterns&#038;#8212&#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":[205,124,123],"class_list":["post-1473","post","type-post","status-publish","format-standard","hentry","category-all","category-frontend","category-tech","tag-design-patterns","tag-124","tag-123"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1473","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=1473"}],"version-history":[{"count":1,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1473\/revisions"}],"predecessor-version":[{"id":1474,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/1473\/revisions\/1474"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}