有一个对象数组。我想把它放在一个循环中,以查找checked是true还是false ..如果它是true,那么我想用每个数组的值连接。请提出任何建议
plugin:[
{checked :true,value:'link', name:'link', id:'linkId'},
{checked :true,value:'plug', name:'plug', id:'plugId'},
{checked :true, value:'switch', name:'switch', id:'switchId'},
]
答案 0 :(得分:0)
你走了:
const plugin = [
{checked :true,value:'link', name:'link', id:'linkId'},
{checked :true,value:'plug', name:'plug', id:'plugId'},
{checked :true, value:'switch', name:'switch', id:'switchId'},
];
render() {
return (
<div>
{ plugin.map(el => {
return el.checked ? el.value : null ;
}) }
</div>
)
}