cocos3.4.2 微信开放域给排行榜上面的图片或头像添加点击事件,点击触发的位置不准确,偏上

import style from ‘./render/style’

import template from ‘./render/template’

import Layout from ‘./engine’

let __env = GameGlobal.wx || GameGlobal.tt || GameGlobal.swan;

let sharedCanvas = __env.getSharedCanvas();

let sharedContext = sharedCanvas.getContext(‘2d’);

function draw() {

Layout.clear();

Layout.init(template, style);

Layout.layout(sharedContext);

}

function updateViewPort(data) {

Layout.updateViewPort({

    x: data.x,

    y: data.y,

    width: data.width,

    height: data.height,

});

}

__env.onMessage(data => {

if (data.type === 'engine' && data.event === 'viewport') {

    updateViewPort(data);

    draw();

    let share = Layout.getElementsByClassName("listHeadImg");

    console.log("share", share)

    for (let i = 0; i < share.length; i++) {

        console.log("scooooooo", share[i])

        share[i].on('click', (e) => {

            console.log("22222222")

        });

    }

}

});

1662640131087
实际触发的位置在这一部分

触发的边界是Button的大小,而不是背景图的大小,背景与Button大小不一致会产生这种现象