import React from 'react'; import './index.less'; import CheckboxItem from '../CheckboxItem'; function AnswerCheckbox(props) { const { selected = [], answer = [], show, list = [], onChange } = props; // const trueList = []; const falseList = []; const map = {}; answer.forEach(row => { map[row] = true; }); selected.forEach(row => { if (!map[row]) falseList.push(row); }); return (
{list.map((item) => { return (
= 0 ? 'true' : ''} ${falseList.indexOf(item.value) >= 0 ? 'false' : ''} ${show ? 'show' : ''}`} onClick={() => { const index = selected.indexOf(item.value); if (index >= 0) { selected.splice(index, 1); } else { selected.push(item.value); } if (onChange) onChange(selected); }}> = 0} />
{item.label}
); })}
); } AnswerCheckbox.propTypes = {}; export default AnswerCheckbox;