The method of introducing jquery in VUE-CLI

Source: Internet
Author: User

The method of introducing jquery in VUE-CLI

Previously wrote Vue Project did not introduce jquery, today, a small group of friends asked me this question, I have to do a bit, the method is as follows:

Let's go into the Webpack.base.conf.js file and start at the top so we need to add a line of code

Become this

varPath = require ('Path')varUtils = require ('./utils')varWebpack = require ("Webpack")//This is the one we addedvarConfig = require ('.. /config')varVueloaderconfig = require ('./vue-loader.conf')

and join the module.exports inside.

  plugins: [    new webpack.optimize.CommonsChunkPlugin ('common.js')  ),    new  webpack. Provideplugin ({    "jquery",    "jquery "    })    ],

We introduced webpack in order to use Webpack object here;

Then add "jquery" to the dependencies in Package.json, "^1.8.0", or you can use NPM install Xxx-save to generate

And then we'll be able to import jquery into the main.js.

Finally, restart the project

At the end of the year, go to the waves.

The method of introducing jquery in VUE-CLI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.