The front-end implements passing parameters between the article list and article details to jump to the corresponding page

The article details page is reused. By passing the Id parameter, the jump from the article list to the article details page is realized. The details page content of different page jumps is also different.
Idea: id is used as a parameter, you need to pass the parameter on the list page first, and then get the id through the interface on the details page, so that you can get the content of the list article.
1. Pass parameters on the list page, define click events, click on the list, trigger events, and send parameters.
insert image description here
Click event: the newsClick
parameter passing statement is written in the click method
insert image description here
2. On the details page, get the passed parameter id, and also write it in the method.
insert image description here
Define a local id on the details page to accept the passed parameter id, and connect with the interface.
this.id=this.$route.query.id route parameter

In this way, you can jump between two pages with a parameter id to achieve page reuse

Guess you like

Origin blog.csdn.net/weixin_44227395/article/details/103664535