basic.js 713 B

1234567891011121314151617181920212223
  1. export const basic = {
  2. methods: {
  3. $emit(...args) {
  4. this.$emit(...args);
  5. },
  6. getRect(selector, all) {
  7. return new Promise((resolve) => {
  8. uni.createSelectorQuery()
  9. .in(this)
  10. [all ? 'selectAll' : 'select'](selector)
  11. .boundingClientRect((rect) => {
  12. if (all && Array.isArray(rect) && rect.length) {
  13. resolve(rect);
  14. }
  15. if (!all && rect) {
  16. resolve(rect);
  17. }
  18. })
  19. .exec();
  20. });
  21. }
  22. }
  23. };