B
B
birdzxc2021-09-17 20:43:58
Vue.js
birdzxc, 2021-09-17 20:43:58

Vue refuses to read use to connect Vuex?

Good afternoon. After looking at various topics on connecting, vuex wrote his own file, but when loading the site, an error pops up in the console: Cannot read property 'use' of undefined . It gives the fifth line for an error. What are the options to fix this? VSCode gives this: Property 'use' does not exist on type 'typeof import .

import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex);

const store = new Vuex.Store({});

export default store;


Versions: "vue": "^3.0.0"
"vuex": "^4.0.2"

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Yarkov, 2021-09-17
@yarkov Vue.js

Why are you squeamish about documentation?
https://next.vuex.vuejs.org/guide/#the-simplest-store

L
low molecular macro, 2021-09-17
@molekulyarniy

because you are using .use with the class and not with the application instance

B
birdzxc, 2021-09-17
@birdzxc

Error resolved. I corrected the code for Vuex4 and entered this command: npm install --save [email protected] .
For yarn: yarn add [email protected]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question