This is an article for help. It is the first time for me to use VUE-CLI3 and develop wechat public account.

The thing is, due to business requirements, the public account needs to be logged in by mobile phone, and is not bound to wechat signal, so it can only be implemented by the common token verification of login status.

The login process is as follows:

Locate the mounted(){} function on the login page, clear the token, cache the token, encapsulate the request header, and verify the token successfully. If the request fails, the login page is displayed

Normal login operation, Web developer tools and Android beta run down and everything is fine!



Next, I tested ios, login jump to make a request, everything was normal, but when I closed the wechat browser and opened it again, the problem came, the request error, prompting “not logged in”!

I checked and found that the token in localStorage cache is missing! So I took Android to test again, and found that the token in the cache was still there, at this time I suspected that there was a problem with ios wechat browser, exit will clear localStorage cache, so I changed to sessionStorage, huh?? Gone too!! Don’t panic, try cookies, huh?? Neither!!

At this time, I attributed the problem to ios wechat browser will clear the cache, so I randomly wrote a parameter in the cache to test, when I closed the browser, I found this parameter is still there!! Still there!! What’s going on? Does my token not deserve to live in cache??



So I went back to my code, commented out the login page cache operation, and found the token cache down!

Here’s what I look like



Mounted (){} on the login page, restore the token for both applications and for both applications. Mounted (){} on the login page, restore the token for both applications and for both applications. Mounted (){} Mounted (){} specifies the time stamp in the login page. After logging in to the B page, I mounted(){} specifies the timestamp in the login page. After logging in to the B page, I mounted(){} specifies the timestamp in the login page. A second timestamp came out!!

The process is as follows:

Mounted (){} is displayed on the login page. If the login is successful, go to B. Close the browser and display the timestamp in the mounted(){} function



This problem did not occur after I re-tested android. I have not solved it yet and have not found the cause of this problem. I can only temporarily think it is a bug of ios wechat browser. Hope to have big guy can help solve a puzzle, or tell me is I which place write wrong, grateful endless!!