我想从 JSON 打印一个布尔值到一个表中,如果我直接访问状态字段,这里显示一个空值是一个 json 文件的例子:
{
'name':'client'
'status':true,
'method':'masterCard',
'amount':'1700',
}
jsx 文件:
const columns = [
{
title: "name",
dataIndex: "name",
key: "name",
width: "20%"
},
{
title: "status",
dataIndex: "status",
key: "status",
width: "20%"
},
{title: "Method Paiment",
dataIndex: "method",
key: "method",
width: "20%",
}]
我发现的解决方案是做一个条件(真或假):
const columns = [
{
title: "name",
dataIndex: "name",
key: "name",
width: "20%"
},
{
title: "status",
dataIndex: "status",
key: "status",
width: "20%",
render: statut => {
if (statut == true) {
return (
<Tag color="#1890ff" key={statut}>
Is True
</Tag>
);
}
return (
<Tag color="#d48806" key={statut}>
Is False
</Tag>
);
}
},
{title: "Method Paiment",
dataIndex: "method",
key: "method",
width: "20%",
}]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句