mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-05-31 22:19:35 +08:00
【小程序】-- 新增tab,tbs组件,可以左右滑动切换tab
This commit is contained in:
23
app/src/utils/util.ts
Normal file
23
app/src/utils/util.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @description 获取元素节点信息(在组件中的元素必须要传ctx)
|
||||
* @param { String } selector 选择器 '.app' | '#app'
|
||||
* @param { Boolean } all 是否多选
|
||||
* @param { ctx } context 当前组件实例
|
||||
*/
|
||||
export const getRect = (selector: string, all: boolean = false, context?: any) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let qurey = uni.createSelectorQuery()
|
||||
if (context) {
|
||||
qurey = uni.createSelectorQuery().in(context)
|
||||
}
|
||||
qurey[all ? 'selectAll' : 'select'](selector).boundingClientRect(function(rect) {
|
||||
if (all && Array.isArray(rect) && rect.length) {
|
||||
return resolve(rect)
|
||||
}
|
||||
if (!all && rect) {
|
||||
return resolve(rect)
|
||||
}
|
||||
reject('找不到元素')
|
||||
}).exec()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user