Home  >  Q&A  >  body text

javascript - vuejs2.0 is a non-single-page application. How to handle requests for project details?

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

阿神阿神2674 days ago1097

reply all(4)I'll reply

  • 某草草

    某草草2017-06-24 09:46:16

    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.

    reply
    0
  • 阿神

    阿神2017-06-24 09:46:16

    js directly parses the url to get the id

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-24 09:46:16

    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.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-24 09:46:16

    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!

    reply
    0
  • Cancelreply