elementui表格中switch点击无效问题

首先贴上我的代码
在column中加入template,添加上 slot-scope=“score”。
然后switch中绑定state

<el-table-column label="显示与隐藏" width="110" align="center">
	<template slot-scope="scope">
	  <el-switch v-model="scope.row.state" :active-value="1" :inactive-value="0" ></el-switch>
	  <div>{
    
    {
    
    scope.row.state}}</div>
	</template>
</el-table-column>

如果遇到还是无法绑定的情况

表格el-table中绑定ref=“tableref”

<el-table :data="tableData" border style="width: 100%" size='medium' ref="tableref">

switch中绑定change事件

<el-switch @change="changeGoodsState" v-model="scope.row.state" :active-value="1" :inactive-value="0" ></el-switch>

定义change事件对应的方法名

methods: {
    
    
	changeGoodsState(){
    
    
	     this.$refs.tableref.doLayout()
	}
}

猜你喜欢

转载自blog.csdn.net/qq_44718932/article/details/126471993