19

运行我的应用程序时出现此错误:

警告 编译时有 1 个警告 ./src/store/store.js 中的 11:50:40 PM 警告“在 'vuex' 中找不到导出 'createStore'

我安装了 vuexnpm install --save vuex

我正在使用 vue 3

我的 Store.js:

import { createStore } from 'vuex';
import Movie from './Modules/Movie';
import post from './Modules/post';

const store = createStore({
  modules: {
    post,
    Movie,
  },
});

export default store;

我的 main.js:

import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store/store.js';

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

2 回答 2

51

您已经通过运行安装了 Vuex 版本 3.x,npm install --save vuex您应该卸载它,npm uninstall --save vuex然后通过运行以下命令安装与 vue 3 兼容的版本 4:

npm install --save vuex@next

对于使用 Yarn 的人来说,下面是命令

yarn add vuex@next
于 2020-12-04T20:34:20.273 回答
0
$ yarn remove vuex
$ yarn add vuex@next

这解决了我的问题!

于 2022-01-23T07:05:03.500 回答