store’中找不到导出‘store’

store’中找不到导出‘store’

本文介绍了“在‘​​../store’中找不到导出‘store’的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试将我的商店导入我的 Vuex Route-Gard.

HI all I am trying to import my store into my Vuex Route-Gard.

路由器/auth-guard.js

router/auth-guard.js

import {store} from '../store'
export default (to, from, next) => {
if (store.getters.user) {
  next()
} else {
next('/login')
}
}

store/index.js

store/index.js

import {store} from '../store'
export default (to, from, next) => {
if (store.getters.user) {
  next()
 } else {
 next('/login')
 }
}

我得到的错误在../store"中找不到导出store"

The error I am getting export 'store' was not found in '../store'

我的 vue 设置

"dependencies": {
"firebase": "^4.3.0",
"vue": "^2.3.3",
"vue-router": "^2.6.0",
"vuex": "^2.3.1"

推荐答案

我能够通过这个方法解决这个问题.

I was able to resolve this, through this method.

main.js

import {store} from './store'
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {
    App
  },

auth-guard.js

import {store} from '../store'
export default (to, from, next) => {
if (store.getters.user) {
  next()
 } else {
 next('/login')
}
}

store/index.js

Vue.use(Vuex)
export const store = new Vuex.Store({
modules: {
products,
bids,
user
}
})

这篇关于“在‘​​../store’中找不到导出‘store’的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:24