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
import jwt_decode from "jwt-decode";export default {name: "app",created() {if (localStorage.jwtToken) {const decode = jwt_decode(localStorage.jwtToken);this.$store.dispatch("...
·
更多推荐
已为社区贡献3条内容
所有评论(0)