Home  >  Article  >  Web Front-end  >  Does vue have jquery built in?

Does vue have jquery built in?

WBOY
WBOYOriginal
2022-06-09 18:17:322726browse

There is no built-in jquery in vue; if you want to use specific functions of jquery in vue, you need to introduce the jquery package. Introduction method: 1. Modify "package.json" and add the jquery version; 2. Enter "npm install" in the terminal and import the dependencies; 3. Modify the "webpack.base.conf" code; 4. Use "import $ from ' jquery'" can be introduced.

Does vue have jquery built in?

The operating environment of this tutorial: windows10 system, Vue3&&jquery3.4.1 version, Dell G3 computer.

Does vue have built-in jquery

vue does not have built-in jquery

It is completely feasible to use jQuery in the Vue project, and it is completely in line with Vue’s working ideas. In essence, jQ is regarded as Just use it as a Vue plug-in that is not highly adaptable to Vue. You need to complete the two-way binding work yourself.

Using jquery in Vue

In a vue project, when you need to implement certain specific functions, it is not easy to implement it using the mvvm mode. Therefore, the jquery package is introduced to complete the requirements

1. Modify package.json

First, add "jquery" to the dependencies in package.json: "^2.2.3"

Of course you can modify the version you want to introduce. Here is the introduction of 2.2.3

Does vue have jquery built in?

2. Import dependencies

Enter npm install in the terminal to import dependencies.

3. Modify webpack.base.conf 

The code is as follows, see the picture to modify;

var webpack = require("webpack")
rrree

Does vue have jquery built in?

Does vue have jquery built in?

4. Introduce jquery into the component and use it

In which component we want to use the jQuery library, we must first use the following command to introduce jquery, and then It can be used normally

Here we introduce it globally in main.js

plugins: [ 
    new webpack.ProvidePlugin({
          $:"jquery", 
          jQuery:"jquery", 
         "windows.jQuery":"jquery"
 }) 
],

Does vue have jquery built in?

Video tutorial recommendation:jQuery video tutorial

The above is the detailed content of Does vue have jquery built in?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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