Use elementui switch in the switch callback

demand

Doing the project, it is necessary according to the state switch switches to determine whether the front display, need to know the current state of the switch, you need to know which specific companies
write it meet to know the current switching state according to the description official website, but do not know which is a specific company

 <el-switch
       v-model="scope.row.is_show"
       :active-value="1"
       :inactive-value="0"
       active-text
       inactive-text
       @change='changeStatus'
  >
  </el-switch>
 changeStatus(callback){
      console.log(callback)// 0 1 0 1 0 1 状态可以获取到
    }


Then continue to increase a parameter can be resolved where $ event is the current state of the parameters,, and is the company's scope.row.company_id custom id

 <el-switch
    v-model="scope.row.is_show"
    :active-value="1"
    :inactive-value="0"
    active-text
    inactive-text
    @change='changeStatus($event,scope.row.company_id)'
 >
 </el-switch>
  changeStatus($event,num){
      console.log($event)//0 1 0 1
      console.log(num)// 122642  122660
    }

Perfect to solve the problem

Guess you like

Origin www.cnblogs.com/my466879168/p/12155493.html