vue-cli3引入jquery的不同

npm install jquery --save

vue-cli3 配置;
在vue.config.js中

module.exports = {
  // 基本路徑
  baseUrl: './',

  configureWebpack: {
	plugins: [
	  new webpack.ProvidePlugin({
		$:"jquery",
		jQuery:"jquery",
		"windows.jQuery":"jquery"
	  })
	]
  },

  lintOnSave: undefined
}

3以下的配置
webpack.base.conf.js

var webpack = require('webpack')
const ProvidePlugin = new webpack.ProvidePlugin({//引入外部類庫
  $: 'jquery',
  jQuery: 'jquery',
});
module.exports = {
...
plugins: [
    ProvidePlugin,
  ],
...
}

import $ from 'jquery'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章