antvis/wx-f2

tooltip 在ios和android真机小程序上表现不一样

liuOneName opened this issue · 1 comments

环境:正常写逻辑,在真机上查看,
问题: 在ios中 onChange 事件的 items 属性的值 有时是上一次的值(当切换的时候);切换不同的图表 还会唤起之前图表的tooltip
关键代码:

<Canvas
            type="2d"
            canvasId={id}
            id={id}
            className="f2charts"
            onTouchStart={touchStart}
            onTouchMove={touchMove}
            onTouchEnd={touchEnd}
            style={{ width: '100%', height: height + 'rpx' }}
        ></Canvas>
function wrapEvent(e) {
    if (!e) return
    if (!e.preventDefault) {
        e.preventDefault = function () {}
    }
    return e
}
const touchStart = e => {
        canvasElRef.current?.dispatchEvent('touchstart', wrapEvent(e))
    }
    const touchMove = e => {
        canvasElRef.current?.dispatchEvent('touchmove', wrapEvent(e))
    }
    const touchEnd = e => {
        canvasElRef.current?.dispatchEvent('touchend', wrapEvent(e))
    }
chart.tooltip({
            onChange: ev => {
                const items = ev.items
                items[0].name = items[0].title
                items[0].value = (items[0].value * 100).toFixed(1) + '%'
            }
        })

应该是Taro编译有问题,原生写法没问题