{"id":52017,"date":"2024-12-03T16:50:37","date_gmt":"2024-12-03T08:50:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52017\/"},"modified":"2024-12-03T16:50:37","modified_gmt":"2024-12-03T08:50:37","slug":"js%e5%af%b9%e8%b1%a1%e4%b8%ad%e8%b0%83%e7%94%a8%e5%b1%9e%e6%80%a7%e6%96%b9%e6%b3%95%e5%87%ba%e9%94%99%ef%bc%9a%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3-typeerror-this-fn1-is-not-a-function-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52017\/","title":{"rendered":"JS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>JS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f<\/h1>\n<p>\u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300aJS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241118\/1731919922673b00321e414.jpg\" class=\"aligncenter\" title=\"JS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f\u63d2\u56fe\" alt=\"JS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>js\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u4e2d\u7684\u65b9\u6cd5\u9519\u8bef<\/strong><\/p>\n<p>\u5728js\u4ee3\u7801\u4e2d\u9047\u5230\u4ee5\u4e0b\u9519\u8bef\uff1a<\/p>\n<pre>typeerror: this.fn1 is not a function<\/pre>\n<p>\u539f\u56e0\u662f\u4ee5\u4e0b\u4ee3\u7801\u6bb5\uff1a<\/p>\n<pre>test.exec = function() {\n  return fn.fn1();\n}<\/pre>\n<p>\u5176\u4e2d\uff0cfn\u5bf9\u8c61\u5c1a\u672a\u89e3\u6790\u5b8c\u6bd5\uff0c\u56e0\u6b64\u65e0\u6cd5\u5728\u5bf9\u8c61\u5185\u90e8\u5f15\u7528\u5176\u6210\u5458fn1\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u91cd\u5199\u4e3a\uff1a<\/p>\n<pre>test.fn = {\n  fn1: test.a\n};\n\ntest.exec = function() {\n  return test.fn.fn1();\n}<\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u5148\u5c06\u5916\u90e8\u51fd\u6570test.a\u590d\u5236\u5230\u5d4c\u5957\u5bf9\u8c61test.fn\u4e2d\uff0c\u7136\u540e\u518d\u5f15\u7528test.fn\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u8f7b\u677e\u5236\u4f5c\u4e2a\u6027\u5316\u7535\u8111\u56fe\u6807\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>JS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f \u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300aJS\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u65b9\u6cd5\u51fa\u9519\uff1a\u5982\u4f55\u89e3\u51b3 \u201cTypeError: this.fn1 is not a function\u201d\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002 js\u5bf9\u8c61\u4e2d\u8c03\u7528\u5c5e\u6027\u4e2d\u7684\u65b9\u6cd5\u9519\u8bef \u5728js\u4ee3\u7801\u4e2d\u9047\u5230\u4ee5\u4e0b\u9519\u8bef\uff1a typeerror: this.fn1 is not a function \u539f\u56e0\u662f\u4ee5\u4e0b\u4ee3\u7801\u6bb5\uff1a test.exec = function() { return fn.fn1(); } \u5176\u4e2d\uff0cfn\u5bf9\u8c61\u5c1a\u672a\u89e3\u6790\u5b8c\u6bd5\uff0c\u56e0\u6b64\u65e0\u6cd5\u5728\u5bf9\u8c61\u5185\u90e8\u5f15\u7528\u5176\u6210\u5458fn1\u3002 \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u91cd\u5199\u4e3a\uff1a test.fn = { fn1: test.a }; test.exec = function() { return test.fn.fn1(); } \u8fd9\u79cd\u65b9\u5f0f\u5148\u5c06\u5916\u90e8\u51fd\u6570test.a\u590d\u5236\u5230\u5d4c\u5957\u5bf9\u8c61test.fn\u4e2d\uff0c\u7136\u540e\u518d\u5f15\u7528test.fn\u3002 \u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~ \u5982\u4f55\u8f7b\u677e\u5236\u4f5c\u4e2a\u6027\u5316\u7535\u8111\u56fe\u6807\uff1f<\/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-52017","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52017","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=52017"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52017\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}