退出登录

编写 store/modules/user.js

logout({ commit }) {
  return new Promise((resolve) => {
    commit('SET_TOKEN', '')
    commit('SET_ROLES', [])
    Cookies.remove('token')
    Cookies.remove('id')
    resolve()
  })
}

编写 components/Layout/NavBar/index.vue

logout(){
  this.$store.dispatch("user/logout")
  .then(() => {
      this.$router.push({ path: "/login" });
  })
  .catch(() => {
    
  });
}