如下场景:
<el-table-column
label="操作">
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="goList(scope.row.id)">个人信息表</el-button>
</template>
</el-table-column>
1.直接占位符的方式
goList(id){
this.$router.push({path:`/line/${id}`})
}
需要对应路由配置如下:
{
path:'/line/:id',
name:'line',
component:line
}
二、通过路由属性中的name来确定匹配的路由,通过params来传递参数
goList(id){
this.$router.push({ name:"line",params:{ orderId:id }})
}
对应路由配置如下:
{
path:'/line',
name:'line',
component:line
}
三、通过 path来匹配路由,然后通过query来传递参数,传递的参数会暴露在地址栏中
goList(id){
this.$router.push({ path: '/line',query: { orderId:id }})
}
对应路由配置同二