dom.js 924 B

1234567891011121314151617181920212223242526272829
  1. export default Behavior({
  2. methods: {
  3. gettingBoundingClientRect(selector, all) {
  4. return new Promise((resolve, reject) => {
  5. try {
  6. wx.createSelectorQuery()
  7. .in(this)[all ? 'selectAll' : 'select'](selector)
  8. .boundingClientRect((rect) => {
  9. if (all && Array.isArray(rect) && rect.length) {
  10. resolve(rect);
  11. }
  12. else if (!all && rect) {
  13. resolve(rect);
  14. }
  15. else {
  16. reject();
  17. }
  18. })
  19. .exec();
  20. }
  21. catch (err) {
  22. reject(err);
  23. }
  24. });
  25. },
  26. },
  27. });
  28. //# sourceMappingURL=dom.js.map