shifeng1993 / react-native-secharts

一个webview封装的图表组件。基于百度echarts4
MIT License
219 stars 57 forks source link

点击就报错event.persist is not a function,咋回事 #69

Open cyt68 opened 4 years ago

cyt68 commented 4 years ago

点击就报错event.persist is not a function,咋回事

xiangdong9013 commented 4 years ago

我也遇到同样问题,但注释掉react-native-secharts/main/dist/index.js中第67行: _handleMessage = (event) => { //event.persist() 【此处为第67行】 if (!event) return null;

问题解除。

cyt68 commented 4 years ago

这么粗暴吗,哈哈,谢谢

------------------ 原始邮件 ------------------ 发件人: "xiangdong9013"<notifications@github.com>; 发送时间: 2020年5月5日(星期二) 中午1:53 收件人: "shifeng1993/react-native-secharts"<react-native-secharts@noreply.github.com>; 抄送: "陈韵同"<794950251@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [shifeng1993/react-native-secharts] 点击就报错event.persist is not a function,咋回事 (#69)

我也遇到同样问题,但注释掉react-native-secharts/main/dist/index.js中第67行: _handleMessage = (event) => { //event.persist() 【此处为第67行】 if (!event) return null;

问题解除。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

shiguo2021 commented 4 years ago

我用的 try catch

HoPGoldy commented 3 years ago

如果不想修改依赖文件的话可以用下面的方法:

import { Echarts } from 'react-native-secharts';

// 继承图表组件并覆盖 _handleMessage 方法
class MyEcharts extends Echarts {
    constructor(props) {
        super(props)

        const super_handleMessage = this._handleMessage

        this._handleMessage = (event) => {
            // 伪造 persist 并转发给父类方法
            event.persist = () => {}
            super_handleMessage(event)
        }
    }
}

之后直接用该组件代替 Echarts 即可。