bdcommon.js 735 B

1234567891011121314151617181920212223242526272829
  1. var bdcom = {
  2. isObj(object) {
  3. return object && typeof(object) == 'object' && Object.prototype.toString.call(object).toLowerCase() ==
  4. "[object object]";
  5. },
  6. isArray(object) {
  7. return object && typeof(object) == 'object' && object.constructor == Array;
  8. },
  9. compute(objA) {
  10. for (var key in objA) {
  11. if (this.isObj(objA[key])) {
  12. var oA = objA[key];
  13. this.compute(oA);
  14. } else if (!this.isArray(objA[key])) { //子级不是数组时,比较属性值
  15. if (key.indexOf('-') > 0) {
  16. var _key = key.replace("-", "");
  17. objA[_key] = objA[key];
  18. // delete objA[key]; //js方法
  19. }
  20. } else {
  21. var oA = objA[key];
  22. for (var k in oA) {
  23. this.compute(oA);
  24. }
  25. }
  26. }
  27. },
  28. }
  29. module.exports = bdcom;