Skip to content

Instantly share code, notes, and snippets.

@xyzdata
Created July 21, 2017 03:01
Show Gist options
  • Save xyzdata/36be904c705bfe4952122b6d2e63357c to your computer and use it in GitHub Desktop.
Save xyzdata/36be904c705bfe4952122b6d2e63357c to your computer and use it in GitHub Desktop.
ant bugs & solution

Table key / rowKey

Warning: Each record in table should have a unique key prop,or set rowKey to an unique primary key.

// key` prop,or set `rowKey

// ???
// Warning: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key. 

let newClomuns = datas.map(
    (data, index) => {
        // fill columns
        console.log(`index`, index);
    }
);

console.log(`newClomuns`, newClomuns);

// datas {key: '1'}, 后端返回的 json 对象,包含一个 key, 字段!


let newDatas = datas.map(
    (data, index) => {
        data.indexkey = index;
        // data add a new property
        return data;
    }
);

// datas {key: '1'}, 前端, 修改返回的 json 对象,新添加一个 indexkey / key / rowKey, 字段!

solution FE:

datas {key: '1'}, 前端, 修改返回的 json 对象,新添加一个 indexkey / key / rowKey, 字段!

    
const datas = [
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`
    },
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`
    },
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`
    }
];


let newDatas = datas.map(
    (data, index) => {
        data.indexkey = index;
        // data add a new property
        return data;
    }
);

solution BE:

datas {key: '1'}, 后端返回的 json 对象,包含一个 key, 字段!

    
const datas = [
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`,
        key: '1'
    },
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`,
        key: '2'
    },
    {
        mencode: `模块定义!A1`,
        mname: `模块名称 `,
        mcomand: `模块命令`,
        clibs: `类库定义!A1`,
        key: '3'
    }
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment