Vue implements login (there is a login interface in the background) to jump to the home page and display the user name on the home page.

display the login user name on the home page, how to achieve this. Please provide ideas, thank you

Mar.17,2021

Log in successfully and put your information in the cache


The

sessionStorage property allows you to access a sessionStorage object. It is similar to localStorage, except that the data stored in localStorage has no expiration setting, while the data stored in sessionStorage is erased at the end of the page session. The page session persists while the browser is open, and reloading or restoring the page retains the original page session. Opening a page in a new tab or window initiates a new session, which is different from the way session cookies works.

it should be noted that the data saved in both localStorage and sessionStorage is limited to the protocol of the page.

// sessionStorage
sessionStorage.setItem('key', 'value');

// sessionStorage
var data = sessionStorage.getItem('key');

// sessionStorage
sessionStorage.removeItem('key');

// sessionStorage
sessionStorage.clear();

read your reply a few days ago to answer that when you log in, you can save username to (localStorage.username = username) localStorage). If you don't clear it manually, it will always exist. If you want to use it, just pick up the call. Var username = locakStorage.username, ok


your login is realized through the data of api interface. Has the problem been solved? I am also looking for this kind of document

Menu