How does vue prevent $router.back () from jumping out of the current site?

assume that the browser currently opens Baidu home page , and then enter a page of the site in the address bar, which contains a return button with the code as follows:

methods: {
    goBack(){
        this.$router.back()
    }
}

when you click the back button (maybe there is only one back button on the page), the browser will navigate to the Baidu home page , how to prevent this problem?

Jul.15,2021

can judge document.referrer , not your master site directly skip to the home page.


think of a way to store the source address in the route interceptor. If the source address is not a route from the current site, set the source to homepage . When $router.back () , $router.replace (currPath) is fine

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5f4bd-5a868.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5f4bd-5a868.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?