Introduce vant error in Vue (solution)

The first option:

1. Install vant

npm i vant -S

Two: Import the vant package

Write the following code in the main.js file of the Vue project

import Vant from 'vant';

import 'vant/lib/index.css';

Vue.use(Vant);

Note: You may encounter version compatibility problems, and running the project at this time will report yellow

You will find that the project cannot run

should: 

1. Uninstall vant first

npm uninstall vant

Because there may be dependency conflicts, it is generally followed by -f to enforce

2. Reduce the npm version: npm install [email protected] -g

3. Perform the above steps again

or:

1. Uninstall vant first

2. Switch to a different vant version: npm install -S [email protected]

3. After performing the above steps

 important:

vue2 corresponds to vant2, for example
"vant": "^2.12.2",
"vue": "^2.6.10"

Vue3 corresponds to vant3
"vant": "^3.0.1",
"vue": "^3.0.1",

Guess you like

Origin blog.csdn.net/m0_67063430/article/details/128913591