使用 Vuex 时 Vuejs 2 中出现警告

Warning happens in Vuejs 2 when using Vuex

当我尝试使用 Vuex 作为商店时,控制台出现警告。如何解除警告?

下面是警告

enter image description here

下面是package.json

enter image description here

store.js

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex)

    export default new Vuex.Store({
        state: {
            todos: [],
            logs: []
        },
        mutations: {
            ADD_TODO(state, todo) {
                console.log('add todo work')
                state.todos.push(todo)
            },
        },
        actions: {
            addTodo({ commit }, todo) {
                commit('ADD_TODO', todo)
            }
        },
    })

main.js 文件

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui';
import store from './store'

Vue.use(ElementUI);
Vue.config.productionTip = false

new Vue({
  store,
  router,
  render: h => h(App)
}).$mount('#app')

您正在使用仅适用于 Vue 3 的 Vuex 4。对于Vue 2,你必须使用Vuex 3。看看official Vuex documentation上的注释。