Vue.js ';vuex persistedstate';韩元´;t调用操作并重新加载页面

Vue.js ';vuex persistedstate';韩元´;t调用操作并重新加载页面,vue.js,vuex,persistent-storage,Vue.js,Vuex,Persistent Storage,我需要一些帮助 将vuex persistedstate添加到proyect,它似乎不允许我在应用商店中调用我的操作。当我点击试图注销的调度时,页面会重新加载,localStorage会保留登录时获得的相同信息,VueDev tools上的整个Vuex面板会重置 这是我的密码 store.js import Vue from 'vue' import Vuex from 'vuex' import createPersistedState from 'vuex-persistedstate'

我需要一些帮助

将vuex persistedstate添加到proyect,它似乎不允许我在应用商店中调用我的操作。当我点击试图注销的调度时,页面会重新加载,localStorage会保留登录时获得的相同信息,VueDev tools上的整个Vuex面板会重置

这是我的密码

store.js

import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  strict: true,
  plugins: [
    createPersistedState()
  ],
  state: {
    token: null,
    user: null
  },
  mutations: {
    setToken (state, token) {
      console.log('mutation1')
      state.token = token
    },
    setUser (state, userData) {
      console.log('mutation2')
      state.user = userData.username
      state.cargo = userData.cargo
    }
  },
  actions: {
    setToken ({commit}, token) {
      console.log('action1')
      commit('setToken', token)
    },
    setUser ({commit}, userData) {
      console.log('action1')
      commit('setUser', userData)
    }
  }
})
登录组件上的登录方法

async login () {
  try {
    const response = await AuthenticationService.ingresar({
      username: this.username,
      password: this.password
    })
    const { username, cargo, token } = response.data
    this.$store.dispatch('setToken', token)
    this.$store.dispatch('setUser', { username, cargo })
  } catch (error) {
    this.error = error.response.data.error
  }
}
logout () {
  this.$store.dispatch('setToken', null)
  this.$store.dispatch('setUser', null)
  this.$router.push('/')
}
导航栏组件上的注销方法

async login () {
  try {
    const response = await AuthenticationService.ingresar({
      username: this.username,
      password: this.password
    })
    const { username, cargo, token } = response.data
    this.$store.dispatch('setToken', token)
    this.$store.dispatch('setUser', { username, cargo })
  } catch (error) {
    this.error = error.response.data.error
  }
}
logout () {
  this.$store.dispatch('setToken', null)
  this.$store.dispatch('setUser', null)
  this.$router.push('/')
}

如果禁用vuex persistedstate,一切正常。

对不起,我的坏消息。在调用注销功能的链接上获得了一个href=“”。这是重新加载页面而不是调用函数。因此,与国家无关。我花了几个世纪才找到它。无所谓。:)