Implementing parameter jump function in Vue project

Implementing parameter jump function in Vue project

Page Description:

​ Main page: name —> shishengzuotanhuichaxun

insert image description here

The data in the table on this page are obtained from the backend through the interface array object and rendered. Each row of data has a corresponding row id. Our goal is to jump to the corresponding sub-details page according to the different row ids of each row of data in the table.

Subpage (details page): name —> Cinfo

insert image description here

This page is the page to be rendered by calling the corresponding interface after getting the row id

Project introduction and reasons for using parameter jump:

This system uses Vue to build the project framework and uses the component library of the Vant mobile framework for development. The table in the main page is implemented using pure native HTML's th, tr, and td. The Vue directive v-for is used to traverse tr to render data to the table. Therefore, all the detail buttons corresponding to the rendered table data are the same, and the page after clicking is also the same, which violates the project business requirements. Therefore, the implementation of parameter passing is particularly critical. The principle of parameter passing operation is to use the same template (Cinfo), but due to different URL paths, the contents of each sub-page can not affect each other.

Implementation process:

step1:

In the js file under vue-router, modify the route of the sub-details page to:

insert image description here

Add ' /:id ' to the path attribute and add a new name attribute to add the id after the URL when redirecting to enter different sub-detail pages

Step 2:

In the main page, add parameters to the binding event of the detail button, and use the item in v-for, that is, the array object obtained through the interface, as the formal parameter in the click event method.

insert image description here

Notice:
1.@click=detail( item ), when binding a click event to a button, don’t forget to add the item parameter in the brackets!

2. The key value of path in the push() method here uses ES6 syntax –> template string (string literals that allow embedded expressions)

At this point, the row ID is passed as a parameter to the sub-details page after clicking the details button, as shown below:

insert image description here

step3:

Next, we need to get the ID passed from the main page in the sub-details page, use it as a request parameter to call the interface and render the data.

​ The operation to obtain the passed id is as follows:

insert image description here

​ Fixed writing method, don’t ask, I just don’t know how to write it (seek help from the experts!). . .

So far, we have implemented most of the operations of the parameter jump function. The remaining operations of calling the interface by id in the subpage and rendering the data will not be shown.

Summarize:

There are many methods. This method can only jump with a specific parameter, and cannot pass the entire array or object. If you have a better method, please share it. The overall implementation steps of jump with parameters are not difficult, the main thing is the idea. Due to my own lack of ability, this sharing may not be so accurate and detailed. If there are any errors, inappropriateness or ambiguity in the description of all the steps, please point out my mistakes. Thank you very much! Let’s work together and make progress together!

This is the end of this article about implementing the parameter jump function in the Vue project. For more relevant vue parameter jump content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue-Element-Admin integrates its own interface to realize login jump
  • Detailed explanation of Vue's hash jump principle
  • How to implement vue page jump
  • Vue implements login, registration, exit, jump and other functions
  • Routing in Vue is not counted in history operations
  • How to redirect PC address to mobile address in Vue

<<:  How to create a swap partition file in Linux

>>:  How to mount the CD to find the rpm package under Linux

Recommend

Usage of Node.js http module

Table of contents Preface HTTP HTTP Server File S...

Semanticization of HTML tags (including H5)

introduce HTML provides the contextual structure ...

MySQL log settings and viewing methods

MySQL has the following logs: Error log: -log-err...

Use of Linux xargs command

1. Function: xargs can convert the data separated...

The principle and application of MySQL connection query

Overview One of the most powerful features of MyS...

Implementation of CSS loading effect Pac-Man

emmm the name is just a random guess 2333 Preface...

8 ways to manually and automatically backup your MySQL database

As a popular open source database management syst...

HTML+CSS to achieve text folding special effects example

This article mainly introduces the example of rea...

Summary of MySQL slow log related knowledge

Table of contents 1. Introduction to Slow Log 2. ...

Linux system repair mode (single user mode)

Table of contents Preface 1. Common bug fixes in ...

Building .NET Core 2.0 + Nginx + Supervisor environment under Centos7 system

1. Introduction to Linux .NET Core Microsoft has ...

The difference between div and span in HTML (commonalities and differences)

Common points: The DIV tag and SPAN tag treat som...

Detailed explanation of JavaScript prototype and examples

Table of contents The relationship between the co...

Summary of horizontal scrolling website design

Horizontal scrolling isn’t appropriate in all situ...