22 lines
		
	
	
		
			576 B
		
	
	
	
		
			JavaScript
		
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			576 B
		
	
	
	
		
			JavaScript
		
	
	
	
| export var basic = Behavior({
 | |
|   methods: {
 | |
|     $emit: function $emit() {
 | |
|       this.triggerEvent.apply(this, arguments);
 | |
|     },
 | |
|     getRect: function getRect(selector, all) {
 | |
|       var _this = this;
 | |
| 
 | |
|       return new Promise(function (resolve) {
 | |
|         wx.createSelectorQuery().in(_this)[all ? 'selectAll' : 'select'](selector).boundingClientRect(function (rect) {
 | |
|           if (all && Array.isArray(rect) && rect.length) {
 | |
|             resolve(rect);
 | |
|           }
 | |
| 
 | |
|           if (!all && rect) {
 | |
|             resolve(rect);
 | |
|           }
 | |
|         }).exec();
 | |
|       });
 | |
|     }
 | |
|   }
 | |
| }); |