gpt4 book ai didi

vue.js - "export ' 存储 ' was not found in ' ../存储'

转载 作者:行者123 更新时间:2023-12-04 03:10:18 29 4
gpt4 key购买 nike

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

路由器/auth-guard.js

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

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

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

我的 vue 设置
"dependencies": {
"firebase": "^4.3.0",
"vue": "^2.3.3",
"vue-router": "^2.6.0",
"vuex": "^2.3.1"

最佳答案

我能够通过这种方法解决这个问题。
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
}
})

关于vue.js - "export ' 存储 ' was not found in ' ../存储',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45884740/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com