javascript - vuejs2.0 is a non-single-page application. How to handle requests for project details?
阿神
阿神 2017-06-24 09:44:16
0
4
1138

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

阿神
阿神

闭关修行中......

reply all(4)
某草草

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!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template