Vue routing passes parameters to solve the problem of refreshing the page or returning the previous page data into [Object object], and examples

Vue routing passes parameters, refresh page data becomes [Object Object]

reason:

Refresh the page or return to the previous page, vue passes parameters through routing, refreshes the page or returns to the page, and the data accepted by the page becomes [Object Object].

Example:

First of all, we click "Start Plan" to jump to the "Plan Details" page by routing the parameters!
insert image description here

this.$router.push({
    
     name: "plan", query: {
    
     info: item } });

Later, when I arrived at the specified page, I found that the data was normal:

insert image description here

Then click Refresh, or return from the next page, and find that there is no data, and then we find out by printing that the data has become [Object Object]
insert image description here
insert image description here
Solution:

Before passing, convert the passed parameters into JSON format, and pass JSON.parse() on the accepted page to solve the problem

Guess you like

Origin blog.csdn.net/m1009113872/article/details/115425947