帮我优化这段代码 this.tableData = []; this.columnList = [ { prop: "", label: "周一" }, { prop: "", label: "周二" }, { prop: "", label: "周三" }, { prop: "", label: "周四" }, { prop: "", label: "周五" }, { prop: "", lab
时间: 2023-07-13 14:41:23 浏览: 70
vue、react面试题合集 (附答案) 中文PDF版.pdf
可以使用循环来简化代码,如下所示:
```
this.columnList = [];
for (let i = 1; i <= 5; i++) {
this.columnList.push({ prop: "", label: `周${i}` });
}
this.tableData = [];
```
这样可以减少代码冗余,同时也使得代码更易读和维护。
阅读全文