const query = uni.createSelectorQuery().in(this);
query.select('.content').boundingClientRect(content => {
console.log('content高度'+content.height);
query.select('#box').boundingClientRect(box => {
console.log('box高度'+box.top);
}).exec();
}).exec();

- 发布:2023-08-03 16:12
- 更新:2023-08-03 16:21
- 阅读:513
产品分类: uniapp/H5
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 无
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
浏览器平台: Chrome
浏览器版本: 无
项目创建方式: HBuilderX
示例代码:
操作步骤:
const query = uni.createSelectorQuery().in(this);
query.select('.content').boundingClientRect(content => {
console.log('content高度'+content.height);
query.select('#box').boundingClientRect(box => {
console.log('box高度'+box.top);
}).exec();
}).exec();
const query = uni.createSelectorQuery().in(this);
query.select('.content').boundingClientRect(content => {
console.log('content高度'+content.height);
query.select('#box').boundingClientRect(box => {
console.log('box高度'+box.top);
}).exec();
}).exec();
预期结果:
预期输出两个高度
预期输出两个高度
实际结果:
循环控制台输出,直到开发工具崩溃
循环控制台输出,直到开发工具崩溃
bug描述:
当声明一个uni.createSelectorQuery方法
但是嵌套使用时,会无限循环,直到开发工具崩溃
必须声明两个 uni.createSelectorQuery方法
2 个回复
2***@qq.com (作者)
偶尔遇到这个bug,不过不修复也并不影响,我只是提出一下,这样使用有问题,希望这对你们有所帮助
喜欢技术的前端 - QQ---445849201
这样写试试
星空战士
感谢,有用
2023-12-23 15:26