javascript - vue routing - What should I do if the browser return button repeatedly returns to the previously clicked page?
習慣沉默
習慣沉默 2017-07-05 11:06:20
0
1
947

I have a homepage index. Click a button on the homepage to enter another page A. Due to functional requirements, I need to tab switch back and forth between page A and page B with the same jump. The problem now is my index , the three routes A and B are all at the same level, there is no secondary route.
In this way, when I click the return button on the browser or mobile phone, it will jump back and forth to the AB page, and finally return to the index.

This is what it looks like when you click, Index —> A —> B —> A —> B
This is what it looks like when you return, B —> A —> B —> A —> index

I want this effect: no matter how to switch between AB, it will eventually return to index
The return button on the web page can directly return to index, but the browser's own return will return based on the history, or Does Vue have a way to control the browser's back button.
Solution? ? ? ?

習慣沉默
習慣沉默

reply all(1)
大家讲道理

router.replace(location)

It is very similar to router.push, the only difference is that it does not add new records to history, but has the same name as its method - replaces the current history record.

http://router.vuejs.org/zh-cn...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!