注:下面引入方法 以vue3引入为主,vue2引入一样差别不大
1.先下载 jQuery
npm install jquery --save
2.在main.js文件中引入
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import jquery from 'jquery'
createApp(App).use(store).use(router).use(ElementPlus).use(jquery).mount('#app')
3.在vue.config.js中进行配置
const webpack =require('webpack')
module.exports = {
outputDir: 'ILVU',
configureWebpack: {
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
Popper: ["popper.js", "default"]
})
]
}
}