gogoWebsite

This.$ (parameter) in Vue to realize page jumps

Updated to 9 hours ago

In many cases, we will execute a series of methods before clicking the button to jump to the page, which can be done using the this.$(location) to change the url and complete the jump.

push can be followed by an object or a string:

// String
this.$('/home/first')
// The object query is equivalent to sending a get request, and the request parameters are displayed in the browser's address bar
this.$({ path: '/home/first' })
// Named routes params are equivalent to sending a post request, where the request parameters are not displayed and disappear when the page is refreshed
this.$({ name: 'Login', params: { id: } )

// When the routing configuration is changed to
// Routing configuration:

//{path:'/login/:id',name:'Login',component:Login}

// and the request is sent again, the request data will not be lost when the page is refreshed.

Methods for jumping pages and passing parameters:

Since dynamic routing also passes params, path cannot be used with params in the this.$() method, otherwise params will be invalid. The page needs to be specified with name.

and accessed through the name attribute of the route configuration

Define the parameters in the routing configuration file:

/* file*/
import Vue from "vue";
import Router from "vue-router";
import MediaSecond from "@/views/EnterprisePage/MediaMatrix/second"; //Information List

(Router);
export default new Router({
  routes: [ /* Perform routing configuration */
    {
        name: "MediaSecond",
        path: "/MediaSecond",
        component: MediaSecond
    },
  ]
})

/* I need to get a blank line at the back.,Otherwise it won't pass ESlint syntax validation */

Get the page by name, passing params:

this.$({ name: 'MediaSecond',params:{artistName:artistName,imgUrl:imgUrl,type:2} })

Get parameters via this.$ on the target page:

if (this.$ == 2) {
     = ;
} else {
     = ;
}

The page is passed parameters via path/name and query, in this case row is a row of table data

this.$({ name: 'DetailManagement', query: { auditID: , type: '2' } });
this.$({ path: '/DetailManagement', query: { auditID: , type: '2' } });

Get parameters via this.$ on the target page:

this.$