current position:Home>How to implement JS? The address bar changes the page load and refresh, and the selected conditions of the current page remain unchanged as all by default

How to implement JS? The address bar changes the page load and refresh, and the selected conditions of the current page remain unchanged as all by default

2022-02-03 00:22:27 CSDN Q & A

img

img

img

For a long time , With axios The hair get request , The address bar can be changed , But you can't refresh ==




Refer to the answer 1:
  1. Sure Use local storage hold Selected value Save up . Every time I enter the page Read first If there is a local one, assign a value .
  2. Save with interface . Every time I come in, I ask for an interface .

If it is vue It can be used keep-alive cache




Refer to the answer 2:



Refer to the answer 3:

You store the selected tag in the browser cache , Update every time you click , When you enter the page refresh, you can take it out




Refer to the answer 4:



Refer to the answer 5:

The main question is whether there are two :

  1. To refresh the page, you need to select the relevant search options by default ? such as : Province .
  2. Click search options , Need to show data , such as : Complete collection of colleges and Universities .

My advice is :

  1. To refresh the page, you need to select the relevant search options by default , You can get url Medium get Parameters , Then correspond to the options , Highlight the selected
  2. Click search options , Need to show data , stay axios After the request is successful , except histroy.push Out of operation , You also need to render the returned data to the page .



Refer to the answer 6:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030022243997.html

Random recommended