index.vue
<template>  
    <view class="content">  
        <image class="logo" src="/static/logo.png"></image>  
        <view class="text-area">  
            <text class="title">{{title}}</text>  
        </view>  
        <view>  
            <custom-test></custom-test>  
            <custom-test></custom-test>  
            <custom-test></custom-test>  
            <custom-test></custom-test>  
            <custom-test></custom-test>  
        </view>  
    </view>  
</template>  
<script>  
    import customTest from '../../components/custom-test.vue';  
    export default {  
        components: {  
            customTest  
        },  
        data() {  
            return {  
                title: 'Hello'  
            }  
        },  
        onLoad() {  
        },  
        methods: {  
        }  
    }  
</script>  
<style>  
    .content {  
        display: flex;  
        flex-direction: column;  
        align-items: center;  
        justify-content: center;  
    }  
    .logo {  
        height: 200rpx;  
        width: 200rpx;  
        margin-top: 200rpx;  
        margin-left: auto;  
        margin-right: auto;  
        margin-bottom: 50rpx;  
    }  
    .text-area {  
        display: flex;  
        justify-content: center;  
    }  
    .title {  
        font-size: 36rpx;  
        color: #8f8f94;  
    }  
</style>  
custom-test.vue
<template>  
    <view class="wrapper-class">  
        百度小程序uni.createSelectorQuery()bug测试  
    </view>  
</template>  
<script>  
    export default {  
        name: "custom-test",  
        data() {  
            return {  
            };  
        },  
        mounted() {  
            const query = uni.createSelectorQuery().in(this);  
            query.select('.wrapper-class').boundingClientRect(data => {  
                console.log("得到布局位置信息" + JSON.stringify(data));  
                console.log("节点离页面顶部的距离为" + data.top);  
            }).exec();  
            setTimeout(() => {  
                const query = uni.createSelectorQuery().in(this);  
                query.select('.wrapper-class').boundingClientRect(data => {  
                    console.log("得到布局位置信息" + JSON.stringify(data));  
                    console.log("节点离页面顶部的距离为" + data.top);  
                }).exec();  
            }, 3000)  
        }  
    }  
</script>  
<style>  
</style>  
                                    
            
            
            
            
ru1er (作者)
百度原生小程序测试未发现此问题,可以正确获取位置信息,已经将代码上传到附件了。麻烦您这边跟进一下。
2022-02-22 16:52