vue引入靜態(tài)jquery報(bào)錯(cuò)的解決辦法:1、通過“npm install jquery –save”安裝jquery依賴;2、在“vue.config.js”中配置jquery;3、通過“import $ from "jquery";”方式在頁(yè)面中引入jquery即可。
本教程操作環(huán)境:Windows10系統(tǒng)、jquery3.2.1版、DELL G3電腦
vue引入靜態(tài)jquery報(bào)錯(cuò)怎么辦?
關(guān)于vue中引用jquery報(bào)錯(cuò)
vue項(xiàng)目中需要使用jquery時(shí),我們可能安裝了jquery還是會(huì)提示報(bào)錯(cuò),如何解決呢,如下所示:
1.安裝jquery依賴 npm install jquery –save
2.在vue.config.js中配置jquery
const webpack = require('webpack') module.exports = { chainWebpack: config => { config.plugin('provide').use(webpack.ProvidePlugin, [{ $: 'jquery', jquery: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }]) } }
登錄后復(fù)制
3.在頁(yè)面中引入
import $ from "jquery";
登錄后復(fù)制
推薦學(xué)習(xí):《jQuery視頻教程》