静态数据兼容key和name作为列名项
This commit is contained in:
@@ -79,13 +79,13 @@ export default {
|
|||||||
const columns = []
|
const columns = []
|
||||||
this.options.staticData.map((row, i) => {
|
this.options.staticData.map((row, i) => {
|
||||||
const prop = `c${i || ""}`
|
const prop = `c${i || ""}`
|
||||||
this.colConfigs.push({label: row[columnProp], prop})
|
this.colConfigs.push({label: row[columnProp] || row.key, prop})
|
||||||
Object.entries(row).map(([k, v]) => {
|
Object.entries(row).map(([k, v]) => {
|
||||||
if (/^v/.test(k)) {
|
if (/^v/.test(k)) {
|
||||||
const item = this.tableData[k.substring(1) || 0] || {}
|
const item = this.tableData[k.substring(1) || 0] || {}
|
||||||
item[prop] = v
|
item[prop] = v
|
||||||
this.tableData[k.substring(1) || 0] = item
|
this.tableData[k.substring(1) || 0] = item
|
||||||
} else if (k != columnProp) {
|
} else if (![columnProp, 'key'].includes(k)) {
|
||||||
const index = columns.findIndex(e => k == e)
|
const index = columns.findIndex(e => k == e)
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
const item = this.tableData[index] || {}
|
const item = this.tableData[index] || {}
|
||||||
|
|||||||
Reference in New Issue
Block a user