I’m new to vueJS, so I’d like to ask for advice.
Problem description:
Each page asynchronously fetches data in json format, then fills in the data and renders it into the page.
I have a question, that is, if I need to click on an item and pass the ID to another page, how can I get the ID in the new page and then asynchronously obtain the data for rendering?
(The method I can think of currently is to use the setAttribute method of jsp, and then set it to a hidden input, use js to get the value, fill it in the data, and then initiate an asynchronous request)
1. The background of the project is written in java.
2. Currently, routing is not used (I haven’t studied how to use it yet, because the page is intercepted by user login, so I haven’t considered making it into a single-page application)
Ask for guidance
If you don’t use routing, you can think of two methods. One is to add parameters after the url. A.jsp jumps to b.jsp, b.jsp?id=1, and on the b.jsp page, take location.href.split('? id=')[1], another method is to set up cache, localStroage, sessionStroage, etc.
js directly parses the url to get the id
Two ways, if you already have an ID, you can directly obtain the data to be rendered and bury it in the page, and Vue directly obtains the local page data to render; or you can bury the ID and then obtain the data to be rendered asynchronously.
When passing the id to another page, write a method on the other page to get the value of the id, and then send the request!