{"id":4024,"date":"2024-11-10T15:11:20","date_gmt":"2024-11-10T07:11:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/4024\/"},"modified":"2024-11-10T15:11:20","modified_gmt":"2024-11-10T07:11:20","slug":"angular-%e7%bb%84%e4%bb%b6%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f%e5%88%9d%e5%ad%a6%e8%80%85%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/4024\/","title":{"rendered":"Angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u521d\u5b66\u8005\u6307\u5357"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173121300517422.jpg\" class=\"aligncenter\" title=\"Angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u521d\u5b66\u8005\u6307\u5357\u63d2\u56fe\" alt=\"Angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u521d\u5b66\u8005\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<p>\u5728\u6df1\u5165\u7814\u7a76\u751f\u547d\u5468\u671f\u6302\u94a9\u4e4b\u524d\uff0c\u6709\u5fc5\u8981\u5bf9\u4e00\u4e9b\u6838\u5fc3\u4e3b\u9898\u6709\u57fa\u672c\u7684\u4e86\u89e3\u3002\u6839\u636e angular \u6587\u6863\uff1a<\/p>\n<blockquote><p>\n  \u5148\u51b3\u6761\u4ef6 \u5728\u4f7f\u7528\u751f\u547d\u5468\u671f\u94a9\u5b50\u4e4b\u524d\uff0c\u60a8\u5e94\u8be5\u5bf9\u4ee5\u4e0b\u5185\u5bb9\u6709\u57fa\u672c\u7684\u4e86\u89e3\uff1a typescript \u7f16\u7a0b angular \u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u57fa\u7840\u77e5\u8bc6\uff0c\u5982 angular \u6982\u5ff5 \u4e2d\u6240\u8ff0\n<\/p><\/blockquote>\n<p>\u4e00\u65e6\u60a8\u719f\u6089\u4e86\u8fd9\u4e9b\u5148\u51b3\u6761\u4ef6\uff0c\u60a8\u5c31\u53ef\u4ee5\u63a2\u7d22 angular \u63d0\u4f9b\u7684\u5f3a\u5927\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u4e86\u3002<\/p>\n<p>angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u662f angular \u7ec4\u4ef6\u5982\u4f55\u521b\u5efa\u3001\u66f4\u65b0\u548c\u9500\u6bc1\u7684\u6838\u5fc3\u3002\u4e86\u89e3\u8fd9\u4e9b\u751f\u547d\u5468\u671f\u4f7f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u63a7\u5236\u7ec4\u4ef6\u5728\u5176\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u7684\u884c\u4e3a\uff0c\u4ece\u800c\u589e\u5f3a\u529f\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u89e3 angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u6302\u94a9\uff0c\u63d0\u4f9b\u793a\u4f8b\u5e76\u89e3\u91ca\u5176\u5178\u578b\u7528\u4f8b\u3002<\/p>\n<h2> angular \u4e2d\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u662f\u4ec0\u4e48\uff1f <\/h2>\n<p>angular \u63d0\u4f9b\u4e86\u591a\u4e2a\u751f\u547d\u5468\u671f\u94a9\u5b50\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5229\u7528\u8fd9\u4e9b\u94a9\u5b50\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u7684\u4e0d\u540c\u9636\u6bb5\u6267\u884c\u7279\u5b9a\u4ee3\u7801\u3002\u4ece\u521d\u59cb\u5316\u7ec4\u4ef6\u5230\u9500\u6bc1\u5b83\uff0c\u8fd9\u4e9b\u94a9\u5b50\u5e2e\u52a9\u7ba1\u7406\u7ec4\u4ef6\u7684\u72b6\u6001\u3001\u884c\u4e3a\u548c\u8d44\u6e90\u6e05\u7406\u3002<\/p>\n<p>\u8fd9\u662f angular \u4e2d\u6240\u6709\u751f\u547d\u5468\u671f\u94a9\u5b50\u7684\u5217\u8868\uff1a<\/p>\n<ol>\n<li>ngonchanges<\/li>\n<li>ngoninit<\/li>\n<li>ngdocheck<\/li>\n<li>ngaftercontentinit<\/li>\n<li>ngaftercontentchecked<\/li>\n<li>ngafterviewinit<\/li>\n<li>ngafterviewchecked<\/li>\n<li>ngondestroy<\/li>\n<\/ol>\n<p>\u6bcf\u4e2a\u94a9\u5b50\u90fd\u6709\u7279\u5b9a\u7684\u7528\u9014\uff0c\u5e76\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u7684\u7279\u5b9a\u65f6\u95f4\u88ab\u8c03\u7528\u3002\u8ba9\u6211\u4eec\u6df1\u5165\u4e86\u89e3\u6bcf\u4e00\u4e2a\u3002<\/p>\n<hr>\n<h3> 1\u3001ngonchanges <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u8f93\u5165\u5c5e\u6027\u66f4\u6539\u65f6\u8c03\u7528\u3002<\/p>\n<p>\u8fd9\u662f\u6784\u5efa\u7ec4\u4ef6\u540e\u8c03\u7528\u7684\u7b2c\u4e00\u4e2a\u751f\u547d\u5468\u671f\u94a9\u5b50\u3002\u6bcf\u6b21\u8f93\u5165\u5c5e\u6027\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6\u90fd\u4f1a\u89e6\u53d1 ngonchanges \u65b9\u6cd5\u3002\u5f53\u60a8\u60f3\u8981\u6267\u884c\u4ee3\u7801\u4ee5\u54cd\u5e94\u7ec4\u4ef6\u7ed1\u5b9a\u8f93\u5165\u5c5e\u6027\u7684\u66f4\u6539\u65f6\uff0c\u5b83\u7279\u522b\u6709\u7528\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, input, onchanges, simplechanges } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;p&gt;{{ data }}&lt;\/p&gt;`\n})\nexport class samplecomponent implements onchanges {\n  @input() data: string;\n\n  ngonchanges(changes: simplechanges): void {\n    console.log('data changed:', changes.data.currentvalue);\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 2.ngoninit <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u5728\u7ec4\u4ef6\u7b2c\u4e00\u6b21 ngonchanges \u4e4b\u540e\u8c03\u7528\u4e00\u6b21\u3002<\/p>\n<p>ngoninit \u94a9\u5b50\u662f\u5927\u90e8\u5206\u521d\u59cb\u5316\u4ee3\u7801\u6240\u5728\u7684\u5730\u65b9\u3002\u8fd9\u662f\u521d\u59cb\u5316\u5c5e\u6027\u3001\u8bbe\u7f6e\u4efb\u4f55\u6240\u9700\u8ba2\u9605\u6216\u8fdb\u884c\u7ec4\u4ef6\u6240\u4f9d\u8d56\u7684 http \u8c03\u7528\u7684\u597d\u5730\u65b9\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, oninit } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;p&gt;{{ info }}&lt;\/p&gt;`\n})\nexport class samplecomponent implements oninit {\n  info: string;\n\n  ngoninit(): void {\n    this.info = 'component initialized!';\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 3.ngdocheck <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u5728\u6bcf\u6b21\u66f4\u6539\u68c0\u6d4b\u8fd0\u884c\u671f\u95f4\u8c03\u7528\u3002<\/p>\n<p>ngdocheck \u94a9\u5b50\u5141\u8bb8\u60a8\u5b9e\u73b0\u81ea\u5df1\u7684\u53d8\u66f4\u68c0\u6d4b\u7b97\u6cd5\u3002\u8fd9\u5bf9\u4e8e\u8ddf\u8e2a angular \u672c\u8eab\u65e0\u6cd5\u68c0\u6d4b\u5230\u7684\u5bf9\u8c61\u7684\u6df1\u5c42\u53d8\u5316\u975e\u5e38\u6709\u7528\u3002\u4e0d\u8fc7\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\uff0c\u5982\u679c\u4f7f\u7528\u4e0d\u5f53\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, docheck } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;p&gt;{{ count }}&lt;\/p&gt;`\n})\nexport class samplecomponent implements docheck {\n  count: number = 0;\n\n  ngdocheck(): void {\n    console.log('change detection running');\n    this.count++;\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 4.ngaftercontentinit <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u5728\u7b2c\u4e00\u6b21 ngdocheck \u4e4b\u540e\u8c03\u7528\u4e00\u6b21\u3002<\/p>\n<p>\u8fd9\u4e2a\u94a9\u5b50\u5728 angular \u5c06\u5916\u90e8\u5185\u5bb9\u6295\u5f71\u5230\u7ec4\u4ef6\u4e2d\u540e\u88ab\u8c03\u7528\u3002\u5b83\u5bf9\u4e8e\u7528\u4e8e\u5728\u6a21\u677f\u4e2d\u5305\u542b\u5916\u90e8\u5185\u5bb9\u7684\u7ec4\u4ef6\u7279\u522b\u6709\u7528\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, aftercontentinit } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;ng-content&gt;&lt;\/ng-content&gt;`\n})\nexport class samplecomponent implements aftercontentinit {\n  ngaftercontentinit(): void {\n    console.log('content projected');\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 5.ngaftercontentchecked <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u6bcf\u6b21\u68c0\u67e5\u6295\u5f71\u5185\u5bb9\u540e\u8c03\u7528\u3002<\/p>\n<p>\u6bcf\u6b21 angular \u68c0\u67e5\u6295\u5f71\u5230\u7ec4\u4ef6\u4e2d\u7684\u5185\u5bb9\u65f6\u90fd\u4f1a\u6267\u884c ngaftercontentchecked \u751f\u547d\u5468\u671f\u94a9\u5b50\u3002\u5b83\u4e0e ngaftercontentinit \u7c7b\u4f3c\uff0c\u4f46\u5728\u6bcf\u4e2a\u66f4\u6539\u68c0\u6d4b\u5468\u671f\u540e\u8fd0\u884c\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, aftercontentchecked } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;ng-content&gt;&lt;\/ng-content&gt;`\n})\nexport class samplecomponent implements aftercontentchecked {\n  ngaftercontentchecked(): void {\n    console.log('projected content checked');\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 6.ngafterviewinit <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u5728\u7b2c\u4e00\u4e2a ngaftercontentchecked \u4e4b\u540e\u8c03\u7528\u4e00\u6b21\u3002<\/p>\n<p>\u6b64\u751f\u547d\u5468\u671f\u6302\u94a9\u7528\u4e8e\u5728\u7ec4\u4ef6\u7684\u89c6\u56fe\uff08\u4ee5\u53ca\u4efb\u4f55\u5b50\u89c6\u56fe\uff09\u521d\u59cb\u5316\u540e\u6267\u884c\u64cd\u4f5c\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u5728 angular \u6e32\u67d3\u89c6\u56fe\u7684\u5b50\u89c6\u56fe\u540e\u64cd\u4f5c\u6216\u8bfb\u53d6\u5b83\u4eec\u7684\u5c5e\u6027\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, afterviewinit, viewchild, elementref } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;p #textelement&gt;hello, world!&lt;\/p&gt;`\n})\nexport class samplecomponent implements afterviewinit {\n  @viewchild('textelement') textelement: elementref;\n\n  ngafterviewinit(): void {\n    console.log('view initialized:', this.textelement.nativeelement.textcontent);\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 7.ngafterviewchecked <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u6bcf\u6b21\u68c0\u67e5\u7ec4\u4ef6\u89c6\u56fe\u540e\u8c03\u7528\u3002<\/p>\n<p>\u8fd9\u4e2a\u94a9\u5b50\u5728 angular \u68c0\u67e5\u7ec4\u4ef6\u89c6\u56fe\u7684\u66f4\u65b0\u540e\u88ab\u8c03\u7528\u3002\u5b83\u4e0e ngafterviewinit \u7c7b\u4f3c\uff0c\u4f46\u5728\u6bcf\u4e2a\u66f4\u6539\u68c0\u6d4b\u5468\u671f\u540e\u8fd0\u884c\u3002\u8fd9\u53ef\u7528\u4e8e\u5e94\u7528\u4f9d\u8d56\u4e8e\u89c6\u56fe\u4e2d\u66f4\u65b0\u7684\u903b\u8f91\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>import { component, afterviewchecked } from '@angular\/core';\n\n@component({\n  selector: 'app-sample',\n  template: `&lt;p&gt;hello, angular!&lt;\/p&gt;`\n})\nexport class samplecomponent implements afterviewchecked {\n  ngafterviewchecked(): void {\n    console.log('view checked');\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<hr>\n<h3> 8.ngondestroy <\/h3>\n<p><strong>\u7528\u9014\uff1a<\/strong>\u5728 angular \u9500\u6bc1\u7ec4\u4ef6\u4e4b\u524d\u8c03\u7528\u3002<\/p>\n<p>ngondestroy \u94a9\u5b50\u662f\u6267\u884c\u6e05\u7406\u4efb\u52a1\u7684\u5730\u65b9\uff0c\u4f8b\u5982\u53d6\u6d88\u8ba2\u9605\u53ef\u89c2\u5bdf\u5bf9\u8c61\u3001\u5206\u79bb\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u6216\u91ca\u653e\u53ef\u80fd\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\u7684\u8d44\u6e90\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre>import { Component, OnDestroy } from '@angular\/core';\n\n@Component({\n  selector: 'app-sample',\n  template: `&lt;p&gt;Component loaded&lt;\/p&gt;`\n})\nexport class SampleComponent implements OnDestroy {\n  ngOnDestroy(): void {\n    console.log('Component is about to be destroyed');\n  }\n}\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<h2> \u7ed3\u8bba <\/h2>\n<p>\u6709\u6548\u5730\u7406\u89e3\u548c\u4f7f\u7528\u8fd9\u4e9b\u751f\u547d\u5468\u671f\u6302\u94a9\u53ef\u4ee5\u8ba9\u60a8\u5bf9 angular \u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u7ec6\u7c92\u5ea6\u7684\u63a7\u5236\u3002\u4ece ngoninit \u4e2d\u521d\u59cb\u5316\u6570\u636e\u5230 ngondestroy \u4e2d\u6e05\u7406\u8d44\u6e90\uff0c\u751f\u547d\u5468\u671f\u94a9\u5b50\u63d0\u4f9b\u4e86\u52a8\u6001\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u57fa\u672c\u63a7\u5236\u3002<\/p>\n<p>\u5728\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u4e9b\u94a9\u5b50\u5982\u4f55\u5728\u73b0\u5b9e\u4e16\u754c\u7684 angular \u5e94\u7528\u7a0b\u5e8f\u4e2d\u534f\u540c\u5de5\u4f5c\uff0c\u5c55\u793a\u66f4\u590d\u6742\u7684\u751f\u547d\u5468\u671f\u548c\u4ea4\u4e92\u7684\u793a\u4f8b\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fAngular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u521d\u5b66\u8005\u6307\u5357\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u6df1\u5165\u7814\u7a76\u751f\u547d\u5468\u671f\u6302\u94a9\u4e4b\u524d\uff0c\u6709\u5fc5\u8981\u5bf9\u4e00\u4e9b\u6838\u5fc3\u4e3b\u9898\u6709\u57fa\u672c\u7684\u4e86\u89e3\u3002\u6839\u636e angular \u6587\u6863\uff1a \u5148\u51b3\u6761\u4ef6 \u5728\u4f7f\u7528\u751f\u547d\u5468\u671f\u94a9\u5b50\u4e4b\u524d\uff0c\u60a8\u5e94\u8be5\u5bf9\u4ee5\u4e0b\u5185\u5bb9\u6709\u57fa\u672c\u7684\u4e86\u89e3\uff1a typescript \u7f16\u7a0b angular \u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u57fa\u7840\u77e5\u8bc6\uff0c\u5982 angular \u6982\u5ff5 \u4e2d\u6240\u8ff0 \u4e00\u65e6\u60a8\u719f\u6089\u4e86\u8fd9\u4e9b\u5148\u51b3\u6761\u4ef6\uff0c\u60a8\u5c31\u53ef\u4ee5\u63a2\u7d22 angular \u63d0\u4f9b\u7684\u5f3a\u5927\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u4e86\u3002 angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u662f angular \u7ec4\u4ef6\u5982\u4f55\u521b\u5efa\u3001\u66f4\u65b0\u548c\u9500\u6bc1\u7684\u6838\u5fc3\u3002\u4e86\u89e3\u8fd9\u4e9b\u751f\u547d\u5468\u671f\u4f7f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u63a7\u5236\u7ec4\u4ef6\u5728\u5176\u6574\u4e2a\u751f\u547d\u5468\u671f\u4e2d\u7684\u884c\u4e3a\uff0c\u4ece\u800c\u589e\u5f3a\u529f\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u5206\u89e3 angular \u7ec4\u4ef6\u751f\u547d\u5468\u671f\u6302\u94a9\uff0c\u63d0\u4f9b\u793a\u4f8b\u5e76\u89e3\u91ca\u5176\u5178\u578b\u7528\u4f8b\u3002 angular \u4e2d\u7684\u751f\u547d\u5468\u671f\u94a9\u5b50\u662f\u4ec0\u4e48\uff1f angular \u63d0\u4f9b\u4e86\u591a\u4e2a\u751f\u547d\u5468\u671f\u94a9\u5b50\uff0c\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u5229\u7528\u8fd9\u4e9b\u94a9\u5b50\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u7684\u4e0d\u540c\u9636\u6bb5\u6267\u884c\u7279\u5b9a\u4ee3\u7801\u3002\u4ece\u521d\u59cb\u5316\u7ec4\u4ef6\u5230\u9500\u6bc1\u5b83\uff0c\u8fd9\u4e9b\u94a9\u5b50\u5e2e\u52a9\u7ba1\u7406\u7ec4\u4ef6\u7684\u72b6\u6001\u3001\u884c\u4e3a\u548c\u8d44\u6e90\u6e05\u7406\u3002 \u8fd9\u662f angular \u4e2d\u6240\u6709\u751f\u547d\u5468\u671f\u94a9\u5b50\u7684\u5217\u8868\uff1a ngonchanges ngoninit ngdocheck ngaftercontentinit ngaftercontentchecked ngafterviewinit ngafterviewchecked ngondestroy \u6bcf\u4e2a\u94a9\u5b50\u90fd\u6709\u7279\u5b9a\u7684\u7528\u9014\uff0c\u5e76\u5728\u7ec4\u4ef6\u751f\u547d\u5468\u671f\u7684\u7279\u5b9a\u65f6\u95f4\u88ab\u8c03\u7528\u3002\u8ba9\u6211\u4eec\u6df1\u5165\u4e86\u89e3\u6bcf\u4e00\u4e2a\u3002 1\u3001ngonchanges \u7528\u9014\uff1a\u8f93\u5165\u5c5e\u6027\u66f4\u6539\u65f6\u8c03\u7528\u3002 \u8fd9\u662f\u6784\u5efa\u7ec4\u4ef6\u540e\u8c03\u7528\u7684\u7b2c\u4e00\u4e2a\u751f\u547d\u5468\u671f\u94a9\u5b50\u3002\u6bcf\u6b21\u8f93\u5165\u5c5e\u6027\u7684\u503c\u53d1\u751f\u53d8\u5316\u65f6\u90fd\u4f1a\u89e6\u53d1 ngonchanges \u65b9\u6cd5\u3002\u5f53\u60a8\u60f3\u8981\u6267\u884c\u4ee3\u7801\u4ee5\u54cd\u5e94\u7ec4\u4ef6\u7ed1\u5b9a\u8f93\u5165\u5c5e\u6027\u7684\u66f4\u6539\u65f6\uff0c\u5b83\u7279\u522b\u6709\u7528\u3002 \u793a\u4f8b\uff1a import { component, input, onchanges, simplechanges } from &#8216;@angular\/core&#8217;; @component({ selector: &#8216;app-sample&#8217;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-4024","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=4024"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/4024\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=4024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=4024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=4024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}