使用vuex报错“__WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor”

import Vue from ‘vue‘;
import Vuex from ‘vuex‘;

Vue.use(Vuex);

const store = new Vuex.store({
    state:{
        num:"我是vuex1"
    }
});
export default store;

控制台显示报错

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor

(是因为尝试将不是构造器的对象或者变量来作为构造器使用。)

解决办法:

将new Vuex.store中的“store”大写

new vuex.Store

参考:

http://www.cnblogs.com/yufann/p/Vue-Node10.html

原文地址:https://www.cnblogs.com/yandeli/p/10860985.html

时间: 2024-07-31 22:21:42

使用vuex报错“__WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor”的相关文章

VUEX报错 [vuex] Do not mutate vuex store state outside mutation handlers

数组 错误的写法:let listData= state.playList; // 数组深拷贝,VUEX就报错 正确的写法:let listDate= state.playList.slice(); /*不能直接操作state里面的属性,但是可以创建一个副本*/ 对象 错误的写法:let listData= state.playList; // 对象深拷贝,VUEX就报错 正确的写法:let listDate= Object.assign({}, state.playList); /*不能直接操

vuex 报错 hook.flushStoreModules is not a function 偶发性

最近开发项目 用到vuex, 刷新页面后偶发性的报错  hook.flushStoreModules is not a function 但是不影响页面任何功能和vuex的使用 进行了各种尝试仍然不行, 当前开发环境 "vue": "^2.5.2" "vuex": "^3.1.2" vue-cli:2.9.6 解决中.......... 原文地址:https://www.cnblogs.com/wangweizhang/p/1

关于 vuex 报错 Do not mutate vuex store state outside mutation handlers.

10 :问题描述 在使用vuex 时,有时候 我们在mutation中定义好方法,在页面或组件提交时 有可能经常会遇到这个错误:---->>Do not mutate vuex store state outside mutation handlers. 9. 原因: The reason is that arrays are stored as references in Javascript and payload.items is likely to be changed outside

踩坑记录-nuxt引入vuex报错store/index.js should export a method that returns a Vuex instance.

错误 store/index.js代码如下: import Vue from 'vue'; import Vuex from 'vuex'; import city from './moudle/city' Vue.use(Vuex); //构造store const store = new Vuex.Store({ // 模块化 modules: { city: city } }); export default store; 解决办法 根据错误提示,到处一个方法,并在方法里把store导出.

使用CleanWebpackPlugin插件报错原因:CleanWebpackPlugin is not a constructor

1 // webpack版本:4.32.2 2 3 // 抛错原写法 4 const CleanWebpackPlugin = require("clean-webpack-plugin"); 5 6 ... 7 8 plugins: [ 9 new CleanWebpackPlugin(['dist']) 10 ] 11 12 ... 13 14 // 另一种错误写法 15 16 const CleanWebpackPlugin = require("clean-webpa

vue报错集锦

1.vue报错: 没安装 less-loader css-loader style-loader      可能的很大原因:没安装less 2.vuex报错:Computed property "xxx" was assigned to but it has no setter 在使用了vuex的情况下,state时导入的state,在页面中不能直接更改state的值,需要在mutation方法中更改,然后在vue组件中commit该方法 3.iview报错:iview出现col栅格提

vue在IE11报错‘vuex requires a Promise polyfill in this browser.’

报错信息 因为使用了 ES6 中用来传递异步消息的的Promise,而IE浏览器都不支持.(vuex使用了ES6语法) npm install babel-polyfill(安装babel-polyfill) Babel是一个广泛使用的转码器,可以将ES6代码转为ES5代码,从而可以在现有环境执行.所以你可以用ES6编写,而不用考虑环境支持的问题. 修改方法1: 在 Webpack中使用 修改方法2: 在main.js中使用 import"babel-polyfill"; import

解决app store下载反复报错“下载失败,请到下载栏重试”

google了一下,大家的解决办法有: 通过显示出debug栏,重置app store(点击reset application) (Refer to: http://daluo.com/article/15135/) 找个其他的下载源进行下载,例如百度网盘,soft.macx.cn 通过thunder的thunder store下载 将DNS修改为8.8.8.8 最后,我通过下面的方法解决了: 将DNS修改为8.8.8.8 解决app store下载反复报错"下载失败,请到下载栏重试"

上传到App Store时5.5寸图和iPad pro图报错

今天上传App store 中 预览和屏幕快照的时候总是报错,尺寸不对 明明是自己用6p截图的图片,怎么不行呢?最后发现自己截的图尺寸是720?×?1280的而苹果要求的是1242 x 2208 所以, 打开截图 点击工具-调整大小,改成这个1242 x 2208的尺寸上传就好了