This commit is contained in:
2025-04-02 10:35:17 +08:00
commit 89db955ec1
701 changed files with 91082 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import {
getCurrentInstance,
} from 'vue';
export async function getElRect(elClass, instance,option) {
instance = instance ? instance : getCurrentInstance();
const query = uni.createSelectorQuery().in(instance.proxy);
try{
const res= await getEle(query,elClass,option)
return res
}catch(e){
console.log(e);
}
}
async function getEle(query,elClass,option){
return new Promise((resolve, reject)=>{
query.select('.' + elClass).fields({
size: true,
...option
}, res => {
// 如果节点尚未生成res值为null循环调用执行
if (!res) {
return setTimeout(() => {
getEle(query,elClass,option);
}, 10);
}
resolve(res);
}).exec();
})
}
export async function getSafeBottomHeight(className, height = 16) {
const bottomEle = await getElRect(className)
return bottomEle.height + height
}