/如果后端返回给你的数据不是true和false或者是1和2动态绑定怎么做/
<el-switch v-model="scope.row.isOpen" active-color="#13ce66" @change="SwitchChange(scope.row)" :active-value="1" :inactive-value="2"
inactive-color="#ff4949"></el-switch>
:active-value="1"/*开启时的值*/
:inactive-value="2"/*关闭时的值*/
// 开关变化
SwitchChange(event) {
/*点击时他会自动把你绑定的值变更,直接去请求数据就可以了*/
var parms = {
isOpen: event.isOpen,
id: event.id
}
SonList.Openclose(parms).then(res => {
this.$message({
message: res.msg,
type: 'success'
})
this.loading = false
this.getdata()
}).catch(error => {
this.loading = false
console.log(error)
})
console.log(event)
},