头图

vue2写法

      <!-- 此处的 slot-scope="scope"就是作用域插槽 -->
<template slot-scope="scope">
      <!-- 内部获取作用域插槽scope.row      row为当前行的值 -->
     <el-button type="danger" @click="delete(scope.row.id)">删除</el-button>
</template>


<script>
   // 方法拿值
    delete(id){
    console.log(id)
    .....
}
</script>

vue3写法

 <!-- 作用域插槽,此处的 #default="scope"为作用域插槽 -->
  <template #default="scope">
           <!-- 内部获取作用域插槽的值 scope.row      row为当前行的值 -->
              <el-switch v-model="scope.row.mg_state" @click="delete(scope.row.id,scope.row.mg_state)"/>
   </template>

<script>
   // 方法拿值
    delete(id,state){
    console.log(id,state)
    .....
}
</script>

兔子先森
360 声望14 粉丝

致力于新技术的推广与优秀技术的普及。