按行绑定数据
1.需求:
看下图,实现点击每一行的 详情 按钮或其每一行的详情
点击详情按钮前:
点击详情按钮后出现弹窗,弹窗里的信息就是 id对应的数据
实现过程:需要往后台提供的接口里传 此行对应的id
2.代码演示:
<el-table-column prop="sort" label="详情" show-overflow-tooltip>
<template slot-scope="scope">
<el-button icon="el-icon-more" @click="getDetails(scope.row.id)"></el-button>
</template>
</el-table-column>
methods:{
// 详情
getDetails(id) {
// this.details = true
this.$http
.get(
"/pub/getExpertById",
{ params: {expertId:id}},
{
emulateJSON: true,
}
)
.then(({ data }) => {
console.log("详情信息:",data);
});
},
}
3.接口信息
话不多说看图
之前写的忘发布了,看了下应该是写完了。最重要的就是代码演示那块,其他只是辅助理解的。