How to switch the vue page to the top of the scrolling page display
This article introduces the knowledge of "how to switch the vue page to the top of the scrolling page". In the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Objectives:
When listview' enters the details page, the details page is displayed from the top of the page.
2. Let me first check the scrollY of the next two pages, which is different each time, and there is no rule between the listview and the scrollY on the details page.
Third, the solution: when entering the details page, the position of the fixed scrolling page is at the top.
Code implementation: vue is written as follows, as for updated lifecycle
Updated () {window.scroll (0,0);}
Fifth, the problem has been solved, but when the network is slow, you can clearly see that the process of scrolling from the bottom to the top of the page is not very beautiful. This problem can be added by myself to add the mask and loading when the network loads data.
6. Share a way to write about the interceptor that vue enters the main page from the landing page
(1) save to sessionStorage when login.vue login is successful.
SessionStorage.setItem ('isLogin', true)
(2) write in the index.js of Router
Router.beforeEach ((to, from, next) = > {/ /'/'is the routing if of the landing page (to.path = ='/') {sessionStorage.removeItem ('isLogin');} let user = JSON.parse (sessionStorage.getItem (' isLogin')); if (! user & & to.path! ='/') {next ({path:'})} else {next ()})
You can complete the interceptor!
This is the end of the content of "how to switch the vue page to the top of the scrolling page". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!