{"id":3616,"date":"2024-11-10T15:26:22","date_gmt":"2024-11-10T07:26:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3616\/"},"modified":"2024-11-10T15:26:22","modified_gmt":"2024-11-10T07:26:22","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84-js-%e8%84%9a%e6%9c%ac%e8%b0%83%e7%94%a8%e6%8a%a5%e9%94%99%ef%bc%9auncaught-referenceerror-is-not-defined%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3616\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u6211\u7684 JS \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1aUncaught ReferenceError: $ is not defined\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173107189122318.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u6211\u7684 JS \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1aUncaught ReferenceError: $ is not defined\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u6211\u7684 JS \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1aUncaught ReferenceError: $ is not defined\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>js \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1auncaught referenceerror<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u7f51\u4e0a\u4e0b\u8f7d\u4e86\u4e00\u4e2a js \u811a\u672c\uff0c\u4f46\u5728\u8c03\u7528\u65f6\uff0c\u51fa\u73b0\u4ee5\u4e0b\u62a5\u9519\uff1a<\/p>\n<pre>uncaught referenceerror: $ is not defined<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u539f\u56e0\uff1a<\/strong><\/p>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u7531\u4e8e js \u811a\u672c\u4e2d\u4f7f\u7528\u4e86\u672a\u58f0\u660e\u7684\u53d8\u91cf\u6216\u51fd\u6570\u9020\u6210\u7684\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 &#8220;$&#8221; \u7b26\u53f7\uff0c\u4f46\u6ca1\u6709\u5bf9 $ \u53d8\u91cf\u6216 jquery \u5e93\u8fdb\u884c\u58f0\u660e\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6839\u636e\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li> <strong>\u786e\u4fdd jquery \u5df2\u88ab\u5305\u542b\uff1a<\/strong>\u5728\u4f7f\u7528\u4efb\u4f55 jquery \u4ee3\u7801\u4e4b\u524d\uff0c\u5fc5\u987b\u5c06 jquery \u5e93\u5305\u542b\u5230\u60a8\u7684 html \u9875\u9762\u4e2d\u3002\u53ef\u4ee5\u4ece cdn\uff08\u5982 google \u7684 cdn\uff09\u6216\u672c\u5730\u6587\u4ef6\u5305\u542b jquery \u5e93\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/li>\n<\/ol>\n<pre>&lt;script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.6.0\/jquery.min.js\"&gt;&lt;\/script&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>**\u68c0\u67e5 $ \u53d8\u91cf\u7684\u58f0\u660e\uff1a**\u5728\u4f7f\u7528 $ \u53d8\u91cf\u4e4b\u524d\uff0c\u5fc5\u987b\u5bf9\u5176\u8fdb\u884c\u58f0\u660e\u3002\u786e\u4fdd\u4ee3\u7801\u4e2d\u6709\u4e00\u4e2a\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u884c\uff1a<\/li>\n<\/ol>\n<pre>var $ = jQuery;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li> <strong>\u786e\u4fdd\u6b63\u786e\u5f15\u7528\u53d8\u91cf\u6216\u51fd\u6570\uff1a<\/strong>\u9519\u8bef\u6d88\u606f\u8868\u660e\u60a8\u4f7f\u7528\u4e86\u672a\u5b9a\u4e49\u7684 $ \u53d8\u91cf\u3002\u8bf7\u68c0\u67e5\u4ee3\u7801\u4e2d\u5f15\u7528\u7684\u53d8\u91cf\u6216\u51fd\u6570\u662f\u5426\u62fc\u5199\u6b63\u786e\u4e14\u5df2\u6b63\u786e\u58f0\u660e\u3002<\/li>\n<li> <strong>\u68c0\u67e5\u6d4f\u89c8\u5668\u7684\u63a7\u5236\u53f0\uff1a<\/strong>\u5982\u679c\u4e0a\u8ff0\u6b65\u9aa4\u6ca1\u6709\u89e3\u51b3\u95ee\u9898\uff0c\u8bf7\u6253\u5f00\u6d4f\u89c8\u5668\u7684\u5f00\u53d1\u8005\u5de5\u5177\u63a7\u5236\u53f0\uff0c\u67e5\u770b\u662f\u5426\u6709\u4efb\u4f55\u989d\u5916\u7684\u9519\u8bef\u6d88\u606f\u6216\u8b66\u544a\u3002\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u60a8\u4e86\u89e3\u95ee\u9898\u7684\u6839\u6e90\u3002<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u6309\u7167\u8fd9\u4e9b\u6b65\u9aa4\u64cd\u4f5c\uff0c\u60a8\u5e94\u8be5\u53ef\u4ee5\u89e3\u51b3 uncaught referenceerror \u5e76\u6210\u529f\u8c03\u7528\u4e0b\u8f7d\u7684 js \u811a\u672c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6211\u7684 JS \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1aUncaught ReferenceError: $ is not defined\uff1f\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>js \u811a\u672c\u8c03\u7528\u62a5\u9519\uff1auncaught referenceerror \u95ee\u9898\uff1a \u7f51\u4e0a\u4e0b\u8f7d\u4e86\u4e00\u4e2a js \u811a\u672c\uff0c\u4f46\u5728\u8c03\u7528\u65f6\uff0c\u51fa\u73b0\u4ee5\u4e0b\u62a5\u9519\uff1a uncaught referenceerror: $ is not defined \u767b\u5f55\u540e\u590d\u5236 \u539f\u56e0\uff1a \u8fd9\u4e2a\u9519\u8bef\u662f\u7531\u4e8e js \u811a\u672c\u4e2d\u4f7f\u7528\u4e86\u672a\u58f0\u660e\u7684\u53d8\u91cf\u6216\u51fd\u6570\u9020\u6210\u7684\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u4ee3\u7801\u4e2d\u4f7f\u7528\u4e86 &#8220;$&#8221; \u7b26\u53f7\uff0c\u4f46\u6ca1\u6709\u5bf9 $ \u53d8\u91cf\u6216 jquery \u5e93\u8fdb\u884c\u58f0\u660e\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u8981\u89e3\u51b3\u6b64\u95ee\u9898\uff0c\u8bf7\u6839\u636e\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u786e\u4fdd jquery \u5df2\u88ab\u5305\u542b\uff1a\u5728\u4f7f\u7528\u4efb\u4f55 jquery \u4ee3\u7801\u4e4b\u524d\uff0c\u5fc5\u987b\u5c06 jquery \u5e93\u5305\u542b\u5230\u60a8\u7684 html \u9875\u9762\u4e2d\u3002\u53ef\u4ee5\u4ece cdn\uff08\u5982 google \u7684 cdn\uff09\u6216\u672c\u5730\u6587\u4ef6\u5305\u542b jquery \u5e93\u3002\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a &lt;script src=&#8221;https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.6.0\/jquery.min.js&#8221;&gt;&lt;\/script&gt; \u767b\u5f55\u540e\u590d\u5236 **\u68c0\u67e5 $ \u53d8\u91cf\u7684\u58f0\u660e\uff1a**\u5728\u4f7f\u7528 $ \u53d8\u91cf\u4e4b\u524d\uff0c\u5fc5\u987b\u5bf9\u5176\u8fdb\u884c\u58f0\u660e\u3002\u786e\u4fdd\u4ee3\u7801\u4e2d\u6709\u4e00\u4e2a\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u884c\uff1a var $ = jQuery; \u767b\u5f55\u540e\u590d\u5236 \u786e\u4fdd\u6b63\u786e\u5f15\u7528\u53d8\u91cf\u6216\u51fd\u6570\uff1a\u9519\u8bef\u6d88\u606f\u8868\u660e\u60a8\u4f7f\u7528\u4e86\u672a\u5b9a\u4e49\u7684 [&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-3616","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3616","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=3616"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3616\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}