700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > antd table动态表头_React项目使用ant Table组件动态生成columns

antd table动态表头_React项目使用ant Table组件动态生成columns

时间:2019-03-26 09:03:09

相关推荐

antd table动态表头_React项目使用ant Table组件动态生成columns

1.描述:公司做一个后台项目,需要渲染列表,我是用的是ant的Table组件,但是要求根据数据动态生成columns,请问有什么方法可以把一下类似的数据动态生成对应的columns吗?

2.数据结构:const schemasMessage = [

{

"code": "011234567890",

"generalInfo": {

"name": "xx有限公司",

"shortName": "xx",

"taxPayerType": "xx",

"taxPayerTypeId": "1",

"registeredCapital": 500,

"characterOfEconomy": "xxx",

"characterOfEconomyId": "21"

},

"transaction": {

"bankName": "xx",

"bankAccount": "1234567890",

"bankLocation": {

"province": "xx",

"city": xx",

}

},

"location": {

"province": "北京",

"city": "北京",

"district": "海淀区",

"street": "xx",

"address": "xx",

"postCode": "01000000"

},

"contacts": [

{

"name": "xx",

"position": "xx"

},

{

"name": "xx",

"position": "xx"

}

],

"marketing": {}

}]

const columns = [

{title:'Code',dataIndex: 'code',key:'code',fixed: 'left'},

{title: 'GeneralInfo',

children:[

{title:'Name',dataIndex: 'name',key:'name'},

{title:'shortName',dataIndex: 'shortName',key:'shortName'},

]

}, {

title: 'Transaction',

children: [{

title: 'bankName',

dataIndex: 'bankName',

key: 'bankName',

},

{ title: 'bankAccount',

dataIndex: 'bankAccount',

key: 'bankAccount',},

{

title: 'bankLocation',

children: [{

title: 'province',

dataIndex: 'province',

key: 'province',

}, {

title: 'city',

dataIndex: 'city',

key: 'city',

}],

}],

},

{

title: 'contacts',

children: [{

title: 'contacts1',

children:[

{title: 'Name',

dataIndex: 'name',

key: 'name',},

{title: 'position',

dataIndex: 'position',

key: 'position',},

]

},{

title: 'contacts2',

children:[

{title: 'Name',

dataIndex: 'name',

key: 'name',},

{title: 'position',

dataIndex: 'position',

key: 'position',},

]

}],

}];

请问如何实现?

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。