basic.js 576 B

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