basic.js 676B

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