Home > Web Front-end > Front-end Q&A > What to do if vue introduces static jquery and reports errors

What to do if vue introduces static jquery and reports errors

藏色散人
Release: 2023-02-07 10:31:58
Original
2093 people have browsed it

Vue introduces static jquery error reporting solutions: 1. Install jquery dependencies through "npm install jquery --save"; 2. Configure jquery in "vue.config.js"; 3. Through "import $ Just introduce jquery into the page by using "from "jquery";".

What to do if vue introduces static jquery and reports errors

The operating environment of this tutorial: Windows 10 system, jquery version 3.2.1, DELL G3 computer

#What to do when vue introduces static jquery and reports errors ?

About the error when referencing jquery in vue

When jquery needs to be used in the vue project, we may have installed jquery and still get an error. How to solve it, as follows As shown:

1. Install jquery dependency npm install jquery --save

2. Configure jquery in vue.config.js

const webpack = require('webpack')
module.exports = {
  chainWebpack: config => {
    config.plugin('provide').use(webpack.ProvidePlugin, [{
        $: 'jquery',
        jquery: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery'
    }])
  }
}
Copy after login

3. Introduce it into the page

import $ from "jquery";
Copy after login

Recommended learning: "jQuery Video Tutorial"

The above is the detailed content of What to do if vue introduces static jquery and reports errors. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template