Home > Web Front-end > Vue.js > body text

A brief discussion on the method of introducing jquery into vue

青灯夜游
Release: 2020-11-12 17:52:53
forward
2451 people have browsed it

The followingvue.js column will introduce to you the method of introducing jquery into vue. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

A brief discussion on the method of introducing jquery into vue

How to introduce jquery into vue

1: Because vue scaffolding has been installed, jquery needs to be introduced globally in webpack

Open the package.json file and add this line of code to it. What follows jquery is the version. Change it according to your own needs.​

    dependencies:{

  "jquery":"^2.2.3"

       }
Copy after login

​ Then cnpm install in the command line ​

Most people should use the Taobao image, so use cnpm. If you are not, you can use npm to install.

2: Add a line of code to webpack.base.conf.js

let webpack=require("webpack")
Copy after login

3: Add this line of code to the end of module.exports in webpack.base.conf.js,

  plugins: [new webpack.optimize.CommonsChunkPlugin('common.js'),new webpack.ProvidePlugin({
    jQuery: "jquery",
    $: "jquery"})
]
Copy after login

4: Introduce it into main.js and add the following line of code

   import $ from 'jquery'
Copy after login

5: The last step is to run it again, cnpm run dev

related Recommendation:

2020 Summary of front-end vue interview questions (with answers)

vue tutorial recommendation: The latest 5 vue.js in 2020 Video tutorial selection

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of A brief discussion on the method of introducing jquery into vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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