deguodaigou/utils/dist/mixins/basic.js

23 lines
698 B
JavaScript
Raw Normal View History

2019-12-23 14:13:27 +08:00
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();
});
}
}
});