Blame view

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