Home > front end >  Vue - set the global variable, the problem of global function, a great god person ~ ~
Vue - set the global variable, the problem of global function, a great god person ~ ~

Time:09-26

The scenario goes like this:
Shiro + JWT realize the login operation, after the success of the login, generates a jwtToken on results after class Result is returned to the front end,
1. The front end will receive jwtToken into the global variable jwtToken,
(2) and set the jwtToken to request the authorization of the header the head,
Could you tell me the two steps of vue how global variables and functions defined?

CodePudding user response:

Wrote after a successful login cookie in the document. The cookie='(not move yourself baidu, each open pages for cookie, is redirected to the login page if the cookie is empty, ajax headers added unified authorization field

CodePudding user response:

reference 1/f, three dozen soy sauce response:
wrote after a successful login cookie in the document. The cookie='(not move yourself baidu, each open pages for cookie, is redirected to the login page, if the cookie is empty ajax headers added unified authorization field
well then wrote the cookie don't need to define the global variables, right?

CodePudding user response:

Vuex will use

CodePudding user response:

Only need to do inside request interceptor configuration can
Search the vue interceptor
https://blog.csdn.net/weixin_45471782/article/details/100225111
Blog has
Access to the request before the beginning can be defined in the head
  • Related