(Solved) Solve the problem that Vue3 reports an error when using vue add axios: Cannot read properties of undefined (reading 'use')

1: Description of the problem

I am new to front-end. When I was learning Vue's front-end and back-end separation projects, I used vue add axios to install plug-ins to prepare for front-end and back-end data interaction. A Cannot read properties of undefined (reading 'use') error occurred.

Two: Cause of the problem

Vue2 uses: Vue.use(Plugin) when installing plug-ins , but this method is no longer supported in Vue3

Three: Problem Solving

1. Find in the directory src->plugins->axios.js and Vue.use(Plugin)delete or comment it out

2. Add this line of code under main.js

createApp(App).use(store).use(axios).mount('#app')

It’s ready to run

Guess you like

Origin blog.csdn.net/qq_41264451/article/details/128614810