<el-table :data="TableData">
<el-table-column
prop="ID"
type="index"
key="index-column"
:width="50"
label="序号"
align="center"
></el-table-column>
<el-table-column label="任务名称" width="260px" prop="taskName">
</el-table-column>
<el-table-column label="任务UUID" width="280px" prop="taskUuid">
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button
type="primary"
size="mini"
@click="onStart">启动</el-button>
</template>
</el-table-column>
</el-table>
通过el-table-column属性prop获取的taskUuid的值
onStart({ index, row}) {
const that = this;
api.rpa
.startTask(scope.row.taskUuid)
.then(({ success, msg }) => {
that.$message({
message: msg || "提交成功",
type: success ? "success" : "error"
});
})
.catch(res => {
});
}
怎么放到onStart方法中用
<el-button
type="primary"
size="mini"
@click="onStart(scope.row)">启动</el-button>
onStart(row) {
row.taskUuid
}
【以下回答由 GPT 生成】
为了将taskUuid的值传递给onStart方法,你可以进行以下步骤:
propValue
,然后将taskUuid的值赋给它。html <el-table :data="TableData"> <el-table-column prop="ID" type="index" key="index-column" :width="50" label="序号" align="center" ></el-table-column> <el-table-column label="任务名称" width="260px" prop="taskName"> </el-table-column> <el-table-column label="任务UUID" width="280px" prop="taskUuid" :prop-value="scope.row.taskUuid"> </el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button type="primary" size="mini" @click="onStart(scope.row)">启动</el-button> </template> </el-table-column> </el-table>
javascript onStart(row) { const that = this; api.rpa .startTask(row.taskUuid) .then(({ success, msg }) => { that.$message({ message: msg || "提交成功", type: success ? "success" : "error" }); }) .catch(res => { }); }
这样,当点击启动按钮时,onStart方法就能够获取到相应行的taskUuid值并调用对应的api.rpa.startTask()方法。