123456789101112131415161718192021222324252627 |
- export default Behavior({
- methods: {
- gettingBoundingClientRect(selector, all) {
- return new Promise((resolve, reject) => {
- try {
- wx.createSelectorQuery()
- .in(this)[all ? 'selectAll' : 'select'](selector)
- .boundingClientRect((rect) => {
- if (all && Array.isArray(rect) && rect.length) {
- resolve(rect);
- }
- else if (!all && rect) {
- resolve(rect);
- }
- else {
- reject();
- }
- })
- .exec();
- }
- catch (err) {
- reject(err);
- }
- });
- },
- },
- });
|