Solution for page jump failure

Description of the problem: For example, in a large form, half of it is filled out, and suddenly you click the back arrow (that is, the  <-  mark in the upper left corner of the browser), assuming that you have used a prompt box to prompt whether to exit the current page, such as https: http://reacttraining.com/ 

<Prompt message="Are you sure you want to leave?"/>

Then even if you click Cancel, the current url has changed, then continue to edit the form, click submit to jump to the page and use ` window.location.href = ' #/abc'` is not enough, because the url of the current page is already This is it,

Then we just need to find a way to make the url change, we can do this:

location.replace("#/abc?t="+ Date.now())
 // t=Date.now() is to ensure that the url changes; location.replace('newurl') loads a new document to replace the current page

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324673231&siteId=291194637