api.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. String.prototype.splice = function(start = 0, deleteCount = 0, addStr = '') {
  2. if (start < 0) start = this.length + start;
  3. if (deleteCount < 0) deleteCount = 0;
  4. return this.substring(0, start) + addStr + this.substring(start + deleteCount);
  5. }
  6. // #ifndef MP-ALIPAY || H5 || APP-PLUS
  7. const SDKVersion = uni.getSystemInfoSync().SDKVersion;
  8. // #endif
  9. module.exports = {
  10. // #ifndef MP-ALIPAY || H5 || APP-PLUS
  11. versionHigherThan(version = '') {
  12. var v1 = SDKVersion.split('.');
  13. var v2 = version.split('.');
  14. const len = Math.max(v1.length, v2.length);
  15. while (v1.length < len) {
  16. v1.push('0');
  17. }
  18. while (v2.length < len) {
  19. v2.push('0');
  20. }
  21. for (let i = 0; i < len; i++) {
  22. const num1 = parseInt(v1[i]);
  23. const num2 = parseInt(v2[i]);
  24. if (num1 > num2) {
  25. return true;
  26. } else if (num1 < num2) {
  27. return false;
  28. }
  29. }
  30. return true;
  31. },
  32. // #endif
  33. html2nodes(html, tagStyle) {
  34. const Parser = require('./Parser.js');
  35. return Parser(html, tagStyle);
  36. },
  37. css2object(style, tagStyle) {
  38. const CssHandler = require('./CssHandler.js');
  39. return new CssHandler(style, tagStyle)._style;
  40. }
  41. }