how do I control the status of each line based on the backend return value? How do you control each line? Write scope.row.on and report an error directly. Scope, can"t get it
.
this.$get("/api/shop", this.getDate).then(res => {
console.log(this.scope); //undefined
console.log(scope); //scope is not defined
}
<el-table-column width="200%" label="" class="switchVal">
<template slot-scope="scope">
<el-switch
@change="changeSwitch(scope.$index, scope.row)"
v-model="scope.row.on"
active-text=""
inactive-text="">
on-color="-sharp00A854"
on-text=""
on-value="1"
off-color="-sharpF04134"
off-text=""
off-value="0"
>
</el-switch>
</template>
</el-table-column>
changeSwitch(index, row) {
if (row.on) {
this.$confirm("", "", {
confirmButtonText: "",
cancelButtonText: "",
type: "warning"
}).then(() => {
row.on = true
}).catch(() => {
row.on = false
});
}else {
this.$confirm("", "", {
confirmButtonText: "",
cancelButtonText: "",
type: "warning"
}).then(() => {
row.on = false
}).catch(() => {
row.on = true
});
}
},