deguodaigou/utils/dist/mixins/basic.js
2019-12-14 09:20:48 +08:00

23 lines
676 B
JavaScript

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();
});
}
}
});