element表格常用的render集锦


判断字段值

(h, row) => {
  let str = "";
  if (row.stauts == "0") {
    str = "已完成";
  } else {
    str = "未完成";
  }
  return h("span", str);
};

根据 ID 控制表格列是否可编辑

(h, row) => {
  if (row && row.id) {
    return h("span", {
      domProps: {
        innerHTML: row.standardName,
      },
    });
  } else {
    let self = this;
    return h("input", {
      domProps: {
        value: row.standardName,
      },
      class: {
        "el-input__inner": true,
      },
      on: {
        input: this.repairTypeChange.bind(this, event, row),
      },
    });
  }
};
repairTypeChange($event,rowData){
rowData.standardName = event.target.value
}

时间转换

function (h, row) {
  if(row && row.createTime) {
    return h('span',format(row.createTime, 'yyyy-MM-dd'))
  }
}

评论
  目录