import { LightningElement } from 'lwc'; const columns = [ { label: "操作", fieldName: "stepUrl", type: "url", typeAttributes: { label: { fieldName: "stepName" } } }, { label: "日期", fieldName: "createdDate", type: "date", typeAttributes: { month: "numeric", day: "numeric", year: "numeric", hour: "numeric", minute: "numeric" } }, { label: "状态", fieldName: "stepStatus" }, { label: "被分配人", fieldName: "fenpei" }, { label: "评论", fieldName: "pinglun" }, { label: "整体状态", fieldName: "allStatus" } ]; const dataTable=[ { url:'11', createdDate:'2021-02-02', stepStatus:'通过', fenpei:'张三', pinglun:'111', allStatus:'全部通过' } ]; export default class Spls extends LightningElement { get columns() { let tempColumns = columns; if(this.showComments){ tempColumns.push({ label: "Comments", fieldName: "comments" }); } return tempColumns; } }