Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to switch the vue page to the top of the scrolling page display

2025-03-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report