vue 插件提示错误:[vuex] unknown mutation type: addItem

Add.vue:
<template>
  <div>
      <p>标题</p>
      <input type="text" v-model="title"></input>
      <p>新闻内容</p>
      <input type="text" v-model="content"></input>
    <p><button type="buttom" @click="add()">提交</button></p>
    </div>
    </template>

    <script>
        import store from "../../../travel/src/store";
    export default {
        name: "add.vue",
        store:store,
        data(){
            return{
                title:'',
                content:''
            }
        },
        methods:{
            add(){
                store.commit('addItem',{
                    title: this.title,
                    content: this.content
                })
            }
        }
    }
</script>

<style scoped>

</style>


store.vue:
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    lists:[]
  },
  mutations: {
    addItem (state, value) {
        state.lists.push(value)
    }
  },
  actions: {

  },
});


qq__鳡_覺_0
浏览 4680回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP