{"id":6421,"date":"2022-07-16T17:31:56","date_gmt":"2022-07-16T09:31:56","guid":{"rendered":"http:\/\/123.57.164.21\/?p=6421"},"modified":"2022-07-16T17:31:56","modified_gmt":"2022-07-16T09:31:56","slug":"vue%e5%8f%8c%e5%90%91%e7%bb%91%e5%ae%9a%e5%9f%ba%e7%a1%80%e5%8e%9f%e7%90%86-object-defineproperty%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=6421","title":{"rendered":"VUE\u53cc\u5411\u7ed1\u5b9a\u57fa\u7840\u539f\u7406\u2014\u2014Object.defineProperty()\u7684\u4f7f\u7528"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1ahttps:\/\/blog.csdn.net\/qq_41996454\/article\/details\/107988996<\/p>\n\n\n\n<p><strong>1\u3001\u6781\u7b80\u53cc\u5411\u7ed1\u5b9a\u793a\u4f8b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u524d\u7aef\u6709\u5173VUE\u7684\u7b14\u8bd5\u548c\u9762\u8bd5\u4e2d\uff0c\u89c2\u5bdf\u8ba2\u9605\u8005\u6a21\u5f0f\u548cVUE\u4e2d\u53cc\u5411\u7ed1\u5b9a\u7684\u539f\u7406\u8fd9\u4e24\u9053\u9898\u51e0\u4e4e\u662f\u5fc5\u8003\u7684\u4e86\u3002<\/p>\n\n\n\n<p>Vue\u53cc\u5411\u7ed1\u5b9avm\u89c6\u56fe\u6a21\u578b\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u5229\u7528\u4e86Object.defineProperty()\uff0c\u901a\u8fc7\u52ab\u6301setter\uff0c\u5b9e\u73b0<a rel=\"noreferrer noopener\" href=\"https:\/\/so.csdn.net\/so\/search?q=model&amp;spm=1001.2101.3001.7020\" target=\"_blank\">model<\/a>\u5230view\uff0cview\u5230model\u5219\u662f\u4e00\u5806\u4e8b\u4ef6\u76d1\u542c \u8f93\u5165\u6846\u7684input\uff0c\u9009\u62e9\u7ec4\u4ef6\u7684 change\u7b49\u7b49\u3002\u5177\u4f53\u590d\u6742\u4e9b\u7684\u5b9e\u73b0\u5c31\u8981\u770b\u89c2\u5bdf\u8ba2\u9605\u8bbe\u8ba1\u6a21\u5f0f\u4e86\u3002<\/p>\n\n\n\n<p>\u6838\u5fc3\u662f\u901a\u8fc7Object.defineProperty() + addEventListener\uff0c\u5bf9data\u7684\u6bcf\u4e2a\u5c5e\u6027\u8fdb\u884c\u4e86get\u3001set\u7684\u62e6\u622a\u3002\u5176\u5b9e\u53ea\u7528Object.defineProperty()\u5df2\u7ecf\u53ef\u4ee5\u5b9e\u73b0\u53cc\u5411\u7ed1\u5b9a\uff0c\u53ea\u662f\u8fd9\u6837\u505a\u6548\u7387\u5f88\u4f4e\u3002<\/p>\n\n\n\n<p><strong>1.1 Object.defineProperty()<\/strong><\/p>\n\n\n\n<p>Object.defineProperty() \u65b9\u6cd5\u4f1a\u76f4\u63a5\u5728\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u5b9a\u4e49\u4e00\u4e2a\u65b0\u5c5e\u6027,\u6216\u8005\u4fee\u6539\u4e00\u4e2a\u5bf9\u8c61\u7684\u73b0\u6709\u5c5e\u6027\uff0c\u5e76\u8fd4\u56de\u6b64\u5bf9\u8c61\u3002\u8be5\u65b9\u6cd5\u6709\u4e09\u4e2a\u53c2\u6570\uff0c\uff08\u5c5e\u6027\u6240\u5728\u7684\u5bf9\u8c61\uff0c\u4f60\u8981\u64cd\u4f5c\u7684\u5c5e\u6027\uff0c\u88ab\u64cd\u4f5c\u7684\u5c5e\u6027\u7684\u7279\u6027\uff09\uff0c\u793a\u4f8b\u5982\u4e0b\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/ \u793a\u4f8b\nlet _xxObj = {}\n\nObject.defineProperty(_xxObj, 'xx_val', {\n    get: function (_n) {\n          console.log('\u8bfb\u53d6\u65f6get\u88ab\u89e6\u53d1')\n        \t\/\/ \u53ef\u4ee5\u5728\u8fd9\u91cc\u64cd\u4f5c\n          return _n;\n        }\n})\n<\/pre>\n\n\n\n<p><strong>1.2 \u5b9e\u73b0\u8fc7\u7a0b<\/strong><\/p>\n\n\n\n<p><strong>1.2.1 \u5355\u4e2aDOM\u4e0e\u5355\u4e2aObj<\/strong><\/p>\n\n\n\n<p>\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2ainput\u6846\uff0c\u4e00\u4e2a\u7528\u6765\u663e\u793a\u503c\u7684span\u5757\uff0c\u5e76\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a_xxObj\u7684Object\uff0c\u73b0\u5728\u5229\u7528Object.defineProperty() + addEventListener \u6765\u5b9e\u73b0input\u4e2d\u7684value\u4e0e\u8be5xxObj\u4e2d\u7684\u4e00\u4e2a\u540d\u4e3axx_val\u7684\u5c5e\u6027\u7684\u7ed1\u5b9a\u3002\u539f\u7406\u5927\u81f4\u5982\u4e0b\u56fe\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168.png\" alt=\"\" class=\"wp-image-6423\" width=\"538\" height=\"244\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168.png 858w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-300x136.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-768x349.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-830x377.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-230x105.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-350x159.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-168-480x218.png 480w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/figure><\/div>\n\n\n\n<p><br>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> &lt;body>\n    &lt;h1>\u6781\u7b80\u53cc\u5411\u7ed1\u5b9a&lt;\/h1>\n    &lt;input id=\"id_input_01\" type=\"text\"\/>\n    &lt;h3>\u5f53\u524dxx_value\u7684\u503c:&lt;span id=\"id_text_01\">&lt;\/span>&lt;\/h3>\n\n    &lt;script>\n      \/\/ -------------------\u83b7\u53d6\u5143\u7d20--------------------------\n      let eInput01 = document.getElementById(\"id_input_01\");\n      let eText01 = document.getElementById(\"id_text_01\");\n      \n      \/\/ \u5b9a\u4e49\u4e00\u4e2aobj\n      let _xxObj = {\n        xx_val: null,  \/\/ \u8fd9\u91cc\u7684\u5b9a\u4e49xx_val\u5c06\u4f1a\u88ab\u4e4b\u540e\u7684defineProperty()\u4fee\u6539\n      };\n\n      \/\/ ---------------\u5f80Obj\u91cc\u5199\u4fee\u6539Dom\u7684\u64cd\u4f5c-------------------\n      \/* \n      Object.defineProperty() \u65b9\u6cd5\u4f1a\u76f4\u63a5\u5728\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u5b9a\u4e49\u4e00\u4e2a\u65b0\u5c5e\u6027\uff0c\n      \u6216\u8005\u4fee\u6539\u4e00\u4e2a\u5bf9\u8c61\u7684\u73b0\u6709\u5c5e\u6027\uff0c\u5e76\u8fd4\u56de\u6b64\u5bf9\u8c61\u3002\n      *\/\n      Object.defineProperty(_xxObj, \"xx_val\", {\n        get: function () {\n          console.log('\u8bfb\u53d6\u65f6,get\u88ab\u89e6\u53d1')\n        },\n        set:function(_n){\n          console.log(\"\u5199\u5165\u65f6,set\u88ab\u89e6\u53d1\")\n\n          \/\/ \u76f4\u63a5\u5728\u8fd9\u91cc\u64cd\u4f5cDOM \u76f8\u5f53\u4e8e\u5728\u8fd9\u91cc\u5355\u5411\u7ed1\u5b9a\u4e86\u4e00\u6b21 Obj->DOM\n          \/\/ _xxObj -> eInput01 eText01\n          eInput01.value = _n;\n        \n          \/\/ \u8fd9\u91cc\u662f\u5355\u5411\u7ed1\u5b9a\uff0c\u7528\u4e8e\u67e5\u770b\u5f53\u524dvalue\u7684\u503c\n          eText01.innerHTML = _n;\n        }\n      });\n            \n      \/\/ -----------------\u7ed9DOM\u7ed1\u5b9a\u76d1\u542c\u4e8b\u4ef6----------------------------  \n      eInput01.addEventListener(\"keyup\", function(e){\n        console.log(e.target.value);\n\n        \/\/ \u5728\u8fd9\u91cc\u64cd\u4f5cObj\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411\u7ed1\u5b9a\u4e86\u4e00\u6b21 eInput01->_xxObj\n        _xxObj.xx_val = e.target.value;\n        \n      })\n      \n\n    &lt;\/script>\n  &lt;\/body>\n<\/pre>\n\n\n\n<p>\u6548\u679c\u56fe\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169.png\" alt=\"\" class=\"wp-image-6424\" width=\"482\" height=\"470\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169.png 776w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169-300x292.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169-768x748.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169-230x224.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169-350x341.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-169-480x468.png 480w\" sizes=\"(max-width: 482px) 100vw, 482px\" \/><\/figure><\/div>\n\n\n\n<p><strong>1.2.2 \u4e24\u4e2aDOM\u4e0e\u5355\u4e2aObj<\/strong><\/p>\n\n\n\n<p>\u73b0\u5728\u65b0\u589e\u52a0\u4e00\u4e2aid\u4e3a&#8221;id_input_02&#8243;\u7684input\u6846\uff0c\u5e76\u4e0e_xxObj.xx_val\u53cc\u5411\u7ed1\u5b9a\uff0c\u793a\u610f\u56fe\u5982\u4e0b\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170.png\" alt=\"\" class=\"wp-image-6425\" width=\"564\" height=\"263\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170.png 788w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170-300x140.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170-768x359.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170-230x107.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170-350x163.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-170-480x224.png 480w\" sizes=\"(max-width: 564px) 100vw, 564px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> &lt;body>\n    &lt;h1>\u6781\u7b80\u53cc\u5411\u7ed1\u5b9a&lt;\/h1>\n    &lt;input id=\"id_input_01\" type=\"text\"\/>\n    &lt;h3>\u5f53\u524dxx_value\u7684\u503c:&lt;span id=\"id_text_01\">&lt;\/span>&lt;\/h3>\n    &lt;input id=\"id_input_02\" type=\"text\"\/>\n\n    &lt;script>\n      \/\/ -------------------\u83b7\u53d6\u5143\u7d20--------------------------\n      let eInput01 = document.getElementById(\"id_input_01\");\n      let eInput02 = document.getElementById(\"id_input_02\");\n      let eText01 = document.getElementById(\"id_text_01\");\n      \n      \/\/ \u5b9a\u4e49\u4e00\u4e2aobj\n      let _xxObj = {\n        xx_val: null,  \/\/ \u8fd9\u91cc\u7684\u5b9a\u4e49xx_val\u5c06\u4f1a\u88ab\u4e4b\u540e\u7684defineProperty()\u4fee\u6539\n      };\n\n      \/\/ ---------------\u5f80Obj\u91cc\u5199\u4fee\u6539Dom\u7684\u64cd\u4f5c-------------------\n      \/* \n      Object.defineProperty() \u65b9\u6cd5\u4f1a\u76f4\u63a5\u5728\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u5b9a\u4e49\u4e00\u4e2a\u65b0\u5c5e\u6027\uff0c\n      \u6216\u8005\u4fee\u6539\u4e00\u4e2a\u5bf9\u8c61\u7684\u73b0\u6709\u5c5e\u6027\uff0c\u5e76\u8fd4\u56de\u6b64\u5bf9\u8c61\u3002\n      *\/\n      Object.defineProperty(_xxObj, \"xx_val\", {\n        get: function (_n) {\n          console.log('\u8bfb\u53d6\u65f6get\u88ab\u89e6\u53d1')\n          return _n;\n        },\n        set:function(_n){\n          console.log(\"\u5199\u5165\u65f6set\u88ab\u89e6\u53d1\")\n          \n          \/\/ \u76f4\u63a5\u5728\u8fd9\u91cc\u64cd\u4f5cDOM \u76f8\u5f53\u4e8e\u5728\u8fd9\u91cc\u5355\u5411\u7ed1\u5b9a\u4e86\u4e00\u6b21 Obj->DOM\n          \/\/ _xxObj -> eInput01 eInput02 eText01\n          eInput01.value = _n;\n          eInput02.value = _n;\n\n          \/\/ \u8fd9\u91cc\u662f\u5355\u5411\u7ed1\u5b9a\uff0c\u7528\u4e8e\u67e5\u770b\u5f53\u524dvalue\u7684\u503c\n          eText01.innerHTML = _n;\n        }\n      });\n            \n      \/\/ -----------------\u7ed9DOM\u7ed1\u5b9a\u76d1\u542c\u4e8b\u4ef6----------------------------  \n      eInput01.addEventListener(\"keyup\", function(e){\n        console.log(e.target.value);\n\n        \/\/ \u5728\u8fd9\u91cc\u64cd\u4f5cObj\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411\u7ed1\u5b9a\u4e86\u4e00\u6b21 eInput01->_xxObj\n        _xxObj.xx_val = e.target.value;\n      })\n\n      eInput02.addEventListener(\"keyup\", function(e){\n        console.log(e.target.value);\n\n        \/\/ \u5728\u8fd9\u91cc\u64cd\u4f5cObj\uff0c\u76f8\u5f53\u4e8e\u53cd\u5411\u7ed1\u5b9a\u4e86\u4e00\u6b21 eInput02->_xxObj\n        _xxObj.xx_val = e.target.value;\n      })\n\n    &lt;\/script>\n  &lt;\/body>\n<\/pre>\n\n\n\n<p>\u5b9e\u73b0\u6548\u679c\u5982\u4e0b\uff0c\u8fd9\u4e24\u4e2a\u8f93\u5165\u6846\u90fd\u548c_xxObj.xx_value\u5b8c\u6210\u4e86\u53cc\u5411\u7ed1\u5b9a\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-171.png\" alt=\"\" class=\"wp-image-6426\" width=\"303\" height=\"188\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-171.png 464w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-171-300x186.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-171-230x143.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-171-350x217.png 350w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/figure><\/div>\n\n\n\n<p><strong>2\u3001\u601d\u8003<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5f53\u6709\u591a\u4e2aDOM\u548c\u591a\u4e2aObj\u9700\u8981\u53cc\u5411\u7ed1\u5b9a\u7684\u65f6\u5019\u5462\uff1f<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-1024x433.png\" alt=\"\" class=\"wp-image-6427\" width=\"603\" height=\"255\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-1024x433.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-300x127.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-768x325.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-830x351.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-230x97.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-350x148.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172-480x203.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-172.png 1046w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/figure><\/div>\n\n\n\n<p>\u4e0a\u9762\u8fd9\u79cd\u6a21\u5f0f\u6709\u4ec0\u4e48\u95ee\u9898\uff1f<\/p>\n\n\n\n<p>\u7b54\u6848\u663e\u800c\u6613\u89c1\uff0c\u6bcf\u5f53\u8981\u65b0\u589e\u52a0\u4e00\u4e2aObj\u548cDOM\u7684\u53cc\u5411\u7ed1\u5b9a\u65f6\uff0c\u90fd\u8981\u5230\u5bf9\u5e94\u7684Obj\u5b9a\u4e49\u548cDOM\u5b9a\u4e49\u7684\u5730\u65b9\u65b0\u52a0\u4ee3\u7801\u3002\u6d89\u53ca\u5230\u7684DOM\u548cObj\u591a\u4e86\uff0c\u7ef4\u62a4\u8d77\u6765\u5c31\u53d8\u5f97\u975e\u5e38\u9ebb\u70e6\uff0c\u800c\u4e14\u4ee3\u7801\u4e5f\u53d8\u5f97\u5f88\u4e0d\u6613\u8bfb\uff0c\u662f\u4e0d\u7b26\u5408\u201c\u9ad8\u5185\u805a\uff0c\u4f4e\u8026\u5408\u201d\u7684\u539f\u5219\u7684\u3002\u4e8e\u662f\uff0c\u9700\u8981\u5f15\u5165\u89c2\u5bdf-\u8ba2\u9605\u8005\u6a21\u5f0f\u6765\u7b80\u5316\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>\u9605\u8005\u6a21\u5f0f\u5728\u53cc\u5411\u7ed1\u5b9a\u4e2d\u626e\u6f14\u4e86\u4ec0\u4e48\u89d2\u8272\u5462\uff1f\u5b83\u8ba9\u53cc\u5411\u7ed1\u5b9a\u66f4\u6709\u6548\u7387\uff01<\/p>\n\n\n\n<p>\u79c9\u6301\u7740\u6587\u7ae0\u201c\u7b80\u6d01\u201d\u7684\u539f\u5219\uff0c\u8fd9\u7bc7\u6587\u7ae0\u6211\u5c31\u53ea\u4ecb\u7ecd\u5230\u8fd9\u91cc\uff0c\u4e4b\u540e\u6211\u4f1a\u4e13\u95e8\u5199\u4e00\u7bc7\u6709\u5173\u89c2\u5bdf\u8ba2\u9605\u8005\u6a21\u5f0f\u548c\u4e00\u7bc7\u8be6\u89e3vue\u53cc\u5411\u7ed1\u5b9a\u539f\u7406\u7684\u6587\u7ae0\u2026\u656c\u8bf7\u671f\u5f85\u3002<\/p>\n\n\n\n<p>\u53e6\u5916\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u89c2\u5bdf\u8005\u6a21\u5f0f\u548c\u8ba2\u9605\u53d1\u5e03\u6a21\u5f0f\u662f\u6709\u4e00\u4e9b\u5dee\u522b\u7684\u2026<br>\u89c4\u5f8b\u5927\u81f4\u4e3a\uff1aPublishers + Subscribers = Observer Pattern<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173.png\" alt=\"\" class=\"wp-image-6428\" width=\"500\" height=\"241\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173.png 820w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173-300x145.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173-768x371.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173-230x111.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173-350x169.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2022\/07\/\u56fe\u7247-173-480x232.png 480w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/figure><\/div>\n\n\n\n<p><br><\/p>\n\n\n\n<p>\u53c2\u8003\u8d44\u6599\uff1a<a href=\"https:\/\/segmentfault.com\/a\/1190000006599500\">\u5256\u6790Vue\u539f\u7406&amp;\u5b9e\u73b0\u53cc\u5411\u7ed1\u5b9aMVVM<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1ahttps:\/\/blog.csdn.net\/qq_41996454\/article\/details\/10 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6421"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6421"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6421\/revisions"}],"predecessor-version":[{"id":6429,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/6421\/revisions\/6429"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}