<el-switch>的坑

发布时间 2023-09-19 14:10:56作者: 一文搞懂

问题描述:在列表渲染的时候,switchData 被触发,原因是冒号的问题,正确写法 :active-value=1 :inactive-value=-1 active-text="生效" inactive-text="失效"

 
<el-table-column width="240" label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
             XXXX
            <el-switch v-model="scope.row.status" :width="50" @change="switchData($event, scope.row)" inline-prompt
              :active-value=1 :inactive-value=-1 active-text="生效" inactive-text="失效" />
        </template>
      </el-table-column>