vue 报already installed. Vue.use(Vuex) should be called only once

原因是组件重复引用了

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import MyVuex from './store.js'
Vue.use(MyVuex)
 
Vue.config.productionTip = false
 
const state = {
  count: 1
}
 
const store = new MyVuex.Store({
  state
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  components: { App },
  template: '<App/>'
})

可以这样解决

    原文作者:exception
    原文地址: https://segmentfault.com/a/1190000017400802
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞