javascript - What is the difference between router.repalce and router.push in vue2.0? What are the differences in their application scenarios?
ringa_lee
ringa_lee 2017-06-26 10:54:01
0
2
905

In vue2.0, the corresponding router2.0 explains that router.replace is very similar to router.push. The only difference is that router.replace does not add new records to history, but replaces the current ones. history record.
So what are the differences between the two application scenarios?

ringa_lee
ringa_lee

ringa_lee

reply all(2)
Peter_Zhu

You can think of the router as a stack of access records. router.replace() replaces the top of the stack, and router.push() adds a new record to the stack.

Under normal circumstances, to manage forward and backward browsing records, you basically use router.push(), but there are also some special cases where you need to use router.replace(). For example, there is an authorization page. When a user follows a process and requires authorization at a certain step, he or she jumps directly to the authorization page. The authorization page submits an authorization request. After successful authorization, it jumps to the address of the next step in the process. Here, the page of the authorization request should use replace to replace its own access record to prevent the user from jumping to the next step and then pressing the back button to return to the authorization page, resulting in repeated authorization.

大家讲道理

If there is no history, the browser will not be able to find the previous page when it goes back.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template