页面上有一个下拉多选框,选中其中一项隐藏页面表格中的一列,因为是多级表头,所以我用v-if
//v-if=isShow的初始值为true
<el-table-column label="当年材料用量" v-if="operation.isShow">
<el-table-column v-for="(column ,index) in totalColumns.yearMaterials" :key="column.dataIndex" :label="column.text" :prop="column.dataIndex">
<template scope="scope">
{{scope.row[column.dataIndex]}}
</template>
</el-table-column>
</el-table-column>
methods里面的方法,我给下拉框绑定了一个change事件,可是页面完全没效果,还请大神指教:
changeListData(){
console.log(this.operation.checkList)
var listData=this.operation.checkList;
var isShowHide=this.operation.isShow;
this.operation.options.forEach(function(item,index){
listData.forEach(function(value,ind){
if(value==item.dataIndex){
console.log("进来判断了")
if(isShowHide==true){
console.log("小号的if进来判断了")
isShowHide=false
console.log(isShowHide)
}else{
console.log("小号的if失败了")
isShowHide=true
}
console.log(isShowHide)
}
})
})
},
isShowHide 只是你定义的一个变量吧。你想要效果this.operation.isShow=false 或者this.operation.isShow = true这么写吧