test.js 533 B

12345678910111213141516171819
  1. this.checkableData = [{ key: 1 }, { key: 2 }, { key: 3 }, { key: 4 }];
  2. this.keyProp = "key";
  3. this.checked = [1, 2];
  4. let checkableDataKeys = this.checkableData.map(item => {
  5. let keyProps = {};
  6. keyProps[item[this.keyProp]] = true;
  7. return keyProps;
  8. });
  9. console.log(checkableDataKeys);
  10. this.checked.every(item => {
  11. console.log(checkableDataKeys[item]);
  12. return checkableDataKeys[item];
  13. });
  14. this.allChecked =
  15. checkableDataKeys.length > 0 &&
  16. this.checked.length > 0 &&
  17. this.checked.every(item => checkableDataKeys[item]);