判断列表是否展示的简写?

visible 是默认列表页隐藏的,我想让他们等于1的时候展示,但是代码量太多了,希望变成简写

        if (this.batchRule.extendOne === 1) {
            this.columns[20].visible = true
        }
        if (this.batchRule.extendTwo === 1) {
          this.columns[21].visible = true
        }
        if (this.batchRule.extendThree === 1) {
          this.columns[22].visible = true
        }
        if (this.batchRule.extendFour === 1) {
          this.columns[20].visible = true
        }
        if (this.batchRule.extendFive === 1) {
          this.columns[21].visible = true
        }
        if (this.batchRule.extendSix === 1) {
          this.columns[22].visible = true
        }

img


把这些抽成一个字段 = this.columns的下标
例如:this.batchRule.extendIndex = 15;
this.columns[this.batchRule.extendIndex].visible = true

this.columns[20].visible =  this.batchRule.extendOne === 1 || this.batchRule.extendFour === 1
this.columns[21].visible =  this.batchRule.extendTwo === 1 || this.batchRule.extendFive === 1
this.columns[22].visible =  this.batchRule.extendThree === 1 || this.batchRule.extendSix === 1

如有帮助,麻烦点个【采纳此答案】 谢谢啦^.^

const batchRule = Object.getOwnPropertyNames(res.data.batchRule)
this.tableConfig.columns.forEach((item) => {
  if (batchRule.includes(item.field)) item.visible = true
})