{"id":999,"date":"2023-03-12T08:20:03","date_gmt":"2023-03-12T00:20:03","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=999"},"modified":"2023-04-29T13:19:28","modified_gmt":"2023-04-29T05:19:28","slug":"vue-cli-webpack-introduce-jquery-globally","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/12\/vue-cli-webpack-introduce-jquery-globally\/","title":{"rendered":"vue-cli webpack\u5168\u5c40\u5f15\u5165jquery"},"content":{"rendered":"<p>1\u3001\u5b89\u88c5jquery<\/p>\n<pre><code>npm install jquery --save<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>2\u3001\u5728webpack.base.conf.js\u91cc\u52a0\u5165<\/p>\n<pre><code class=\"language-javascript\">var webpack = require(&quot;webpack&quot;)<\/code><\/pre>\n<p>\u5728module.exports\u7684\u6700\u540e\u52a0\u5165<\/p>\n<pre><code class=\"language-javascript\">plugins: [\n new webpack.optimize.CommonsChunkPlugin(&#039;common.js&#039;),\n new webpack.ProvidePlugin({\n    jQuery: &quot;jquery&quot;,\n    $: &quot;jquery&quot;\n })\n]<\/code><\/pre>\n<p>3\u3001\u7136\u540e\u4e00\u5b9a\u8981\u91cd\u65b0 npm run dev<\/p>\n<p>4\u3001\u5728main.js\u6216\u6307\u5b9avue\u6587\u4ef6\u5f15\u5165\u5373\u53ef<\/p>\n<pre><code class=\"language-javascript\">import $ from &#039;jquery&#039;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5b89\u88c5jquery npm install jquery &#8211;save 2\u3001\u5728webpack.base.co [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[278],"class_list":["post-999","post","type-post","status-publish","format-standard","hentry","category-vue","tag-webpack"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=999"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/999\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}