完美解决 Compiled with problems: × ERROR Cannot read properties of undefined (readin

When starting vue ui and using npm run serve to compile and start, the following problems occur:

Compiled with problems:

x

ERROR

Cannot read properties of undefined (reading 'use') TypeError: Cannot read properties of undefined (reading 'use') at eval (webpack-internal:///./src/plugins/element.js:13:45) at ./src/plugins/element.js (http://localhost:8080/js/app.js:96:1) at webpack_require (http://localhost:8080/js/app.js:337:33) at fn (http://localhost:8080/js/app.js:592:21) at eval (webpack-internal:///./src/main.js:5:77) at ./src/main.js (http://localhost:8080/js/app.js:85:1) at webpack_require (http://localhost:8080/js/app.js:337:33) at http://localhost:8080/js/app.js:1517:109 at webpack_require.O (http://localhost:8080/js/app.js:383:23) at http://localhost:8080/js/app.js:1518:53

The screenshot of the error is as follows:

 Solution: 

1. Recreate a new project

2. Reinstall dependencies. I have this problem because my dependencies are not installed properly

npm install -g vue installs global vue

npm install -g @vue/cli installs vue scaffolding, adding an @ is the latest version

3. Modify the code in main.js. The way to import the package is wrong.

import { createApp } from 'vue'
import App from './App.vue'
import router from './router/index'

const app = createApp(App)
app.use(router).mount('#app')

Define a variable to store, use the variable to call

Guess you like

Origin blog.csdn.net/qq_60870118/article/details/129960445