import jwt_decode from "jwt-decode";
export default {
name: "app",
created() {
if (localStorage.jwtToken) {
const decode = jwt_decode(localStorage.jwtToken);
this.$store.dispatch("setIsAuted", !this.isEmpty(decode));
this.$store.dispatch("setUser", decode);
}
},
复制代码
前端 APP.VUE 根组件 引入中间件 jwt-decode,从localStorage 解析token
最新推荐文章于 2024-05-20 09:31:38 发布