-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ele.getBoundingClientRect() promise在支付宝小程序渠道一直不resolve #17351
Comments
This was referenced Feb 22, 2025
ref: https://opendocs.alipay.com/mini/api/na4yun 我看了下支付宝小程序, |
@zhubeniii 临时方案可以试试这个,调用原生的办法去做,前提是识别一下当前使用平台是支付宝 const query = Taro.miniGlobal.createSelectorQuery();
query.select(`#${ref.current.uid}`).boundingClientRect().exec((res) => {
// 这里写你的逻辑
// 这里可以获取节点布局位置信息
console.log("exec", res);
}); 如果你要在useLoad里面获取的话,需要加一个nextTick,Taro和支付宝小程序生命周期有点对不上 useLoad(() => {
Taro.nextTick(() => {
const query = Taro.miniGlobal.createSelectorQuery();
query.select(`#${ref.current.uid}`).boundingClientRect().exec((res) => {
// 这里写你的逻辑
// 这里可以获取节点布局位置信息
console.log("exec", res);
});
});
}); |
18 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
相关平台
支付宝小程序
复现仓库
[email protected]:zhubeniii/taro-getBoundingClientRect-alipay-issue.git
小程序基础库: 2.9.30
使用框架: React
复现步骤
pnpm i
pnpm dev:alipay
启动项目
期望结果
代码走到debugger
实际结果
一直走不到promise.then的回调
环境信息
The text was updated successfully, but these errors were encountered: