加载商店到vue js
Load store into vue js
当我尝试加载页面时,它向我显示错误 "TypeError: Cannot read property 'state' of undefined"。根据文档,我试过这辆巴士没有加载商店。
<template>
<div>
</div>
</template>
<script>
import { store } from '@/components/tenant/store/store'
import Vue from 'vue'
export default {
store:store,
data: () => {
return {
}
}
}
store.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export const userStore = new Vuex.Store({
state: {}
})
也许我误解了你的问题,但是既然你导出的是 const userStore,是不是需要做下面的事情:
import { userStore } from '@/components/tenant/store/store';
当我尝试加载页面时,它向我显示错误 "TypeError: Cannot read property 'state' of undefined"。根据文档,我试过这辆巴士没有加载商店。
<template>
<div>
</div>
</template>
<script>
import { store } from '@/components/tenant/store/store'
import Vue from 'vue'
export default {
store:store,
data: () => {
return {
}
}
}
store.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export const userStore = new Vuex.Store({
state: {}
})
也许我误解了你的问题,但是既然你导出的是 const userStore,是不是需要做下面的事情:
import { userStore } from '@/components/tenant/store/store';