module namespace not found in mapGetters(): cart/,为什么?

628 篇文章 6 订阅
这篇博客探讨了Vuex状态管理库中index.js文件在处理用户状态时可能出现的问题。作者指出,当store的index.js文件里缺少必要的用户登录状态保存和删除功能时,可能导致应用的用户身份验证功能失效。通过示例代码,展示了如何使用mutations来实现`saveUser`和`deleteUser`方法,以确保用户信息的正确存储和清除。
摘要由CSDN通过智能技术生成

因为store的index.js里没有该有的东西吗

index.js

const state = {
  user: null
}
// mutations
const mutations = {
  saveUser(state, {username, id}){
    state.user = {username, id}
  },
  deleteUser(state){
    state.user = null;
  }
}

export default {
  namespaced: true,
  state,
  mutations,
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值