v-for v-if不建议一起用 解决办法 使用 computed

发布时间 2023-12-26 17:49:29作者: xxzhang1437
 <el-table-column
          v-for="(item, index) in newDynamicColumns"
          :key="index"
          :prop="item.prop"
          :label="item.label"
          :align="item.align"
          :width="item.width"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :fixed="item.fixed"
        > </el-table-column>
  computed: {
    newDynamicColumns() {
      let newColumns = [];
      this.dynamicColumn.forEach((item) => {
        if (item.show) {
          newColumns.push(item);
        }
      });
      return newColumns;
    },
  },