当前位置: 首页 > 知识库问答 >
问题:

未捕获的TypeError:(0,vue__网页包_导入的_模块20_Uu.reactive)不是函数-在vue 2中

孟晨朗
2023-03-14

我是Vue js的新手,

控制台错误:

错误

Uncaught TypeError: (0 , vue__WEBPACK_IMPORTED_MODULE_20__.reactive) is not a function - in Vue 2
    at resetStoreState (webpack-internal:///./node_modules/vuex/dist/vuex.esm-bundler.js:221:64)
    at new Store (webpack-internal:///./node_modules/vuex/dist/vuex.esm-bundler.js:1031:3)
    at eval (webpack-internal:///./src/store/index.js:7:13)
    at Module../src/store/index.js (app.js:186:1)
    at __webpack_require__ (app.js:268:33)
    at fn (app.js:513:21)
    at eval (webpack-internal:///./src/main.js:12:70)
    at Module../src/main.js (app.js:175:1)
    at __webpack_require__ (app.js:268:33)
    at app.js:1385:109

我将图片附在这里:https://postimg.cc/FfVC6dmw


    import Vue from "vue";
    import Vuex from 'vuex';
    
    Vue.use(Vuex);
    
    const store = new Vuex.Store({
        state:{
            message:"Hello, From Vuex"
        },
        mutations:{},
        actions:{},
        getters:{}
    
    })
    
    export default store;

=


    import Vue from 'vue'
    import App from './App.vue'
    import StoreC from './store/index'
    
    Vue.config.productionTip = false
    
    new Vue({
        StoreC,
        render: h => h(App),
    }).$mount('#app')


我已附上包裹。下面是json。


    {
      "name": "vuex-shop",
      "version": "0.1.0",
      "private": true,
      "scripts": {
        "serve": "vue-cli-service serve",
        "build": "vue-cli-service build",
        "lint": "vue-cli-service lint"
      },
      "dependencies": {
        "core-js": "^3.8.3",
        "vue": "^2.6.14",
        "vuex": "^4.0.2"
      },
      "devDependencies": {
        "@babel/core": "^7.12.16",
        "@babel/eslint-parser": "^7.12.16",
        "@vue/cli-plugin-babel": "~5.0.0",
        "@vue/cli-plugin-eslint": "~5.0.0",
        "@vue/cli-service": "~5.0.0",
        "eslint": "^7.32.0",
        "eslint-plugin-vue": "^8.0.3",
        "install-peers": "^1.0.3",
        "vue-template-compiler": "^2.6.14"
      },
      "eslintConfig": {
        "root": true,
        "env": {
          "node": true
        },
        "extends": [
          "plugin:vue/essential",
          "eslint:recommended"
        ],
        "parserOptions": {
          "parser": "@babel/eslint-parser"
        },
        "rules": {}
      },
      "browserslist": [
        "> 1%",
        "last 2 versions",
        "not dead"
      ]
    }

共有1个答案

欧阳绪
2023-03-14

您的Vue版本与Vuex版本不兼容。

Vuex 3与Vue 2配合使用:https://v3.vuex.vuejs.org/

Vuex 4与Vue 3配合使用:https://vuex.vuejs.org/

您特别需要:npm installvuex@3.6.2

 类似资料:
  • 问题内容: 我是jQuery的新手,并在旧的教程上使用了以下代码段: 但是我得到这个错误 未捕获的TypeError:$ .ajax(…)。成功不是函数 在 我想知道这里有什么问题吗? 问题答案: 对ajax的调用应如下所示: 您没有方法链接成功函数,它是字典参数中的条目之一。

  • 不知何故,我无法正确使用slick carousel(http://kenwheeler.github.io/slick/)。 我得到以下错误: 我正在javascript文件中运行以下代码: 我已经在Bower中包含了最新的jQuery版本(2.1.4)。我还尝试在布局模板文件的头部包含jQuery CDN,但这也没有解决任何问题。 唯一奇怪的是,当我不使用函数来调用滑块时,它确实起作用,但它给

  • 我正在使用InstaFeed从Instagram获取图片并在网站上展示。 这是我的代码: 我对JS和JQuery很陌生,但我不知道为什么会出现这个错误。错误在以下行: var images=$(“#instafeed”)。find('a');

  • 所以我想使用Apollo客户机react钩子“usequery”查询运行Apollo服务器的graphql后端。 但定义的查询常量将返回一个错误,即:uncattle typeerror:(...)不是一个函数,因此页面根本不会呈现。 我的ApolloClient和提供程序设置如下: 组件/游戏/gamePage.js: 当加载应用程序时,它会给我上面提到的错误。我就像在两个小时内谷歌和YouTu

  • 问题内容: 我正在努力推动 作为新的ID和json字符串的值。但是它给出了以下错误 提前谢谢您的回复 问题答案: 要使用Array的push函数,您的var必须是一个Array。 更改为以下内容: 包含的数组项将是typeof对象,您可以执行以下操作: 注意:请保持一致。在我的示例中,一个数组包含对象属性,而另一个仅包含对象属性。如果我使用或进行迭代,那么我将无法始终检查一个属性,因为我的示例包含

  • 我在控制台中得到以下错误:。 也许问题出在不推荐的JSXTransformer上(https://facebook.github.io/react/blog/2015/06/12/deprecating-jstransform-and-react-tools.html)。建议使用Babel代替(在我的例子中,使用Babel!view/todolist代替jsx!view/todolist)。我对此