react-native-secharts icon indicating copy to clipboard operation
react-native-secharts copied to clipboard

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

Open cyt68 opened this issue 4 years ago • 4 comments

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

cyt68 avatar Apr 27 '20 01:04 cyt68

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

问题解除。

xiangdong9013 avatar May 05 '20 05:05 xiangdong9013

这么粗暴吗,哈哈,谢谢

------------------ 原始邮件 ------------------ 发件人: "xiangdong9013"<[email protected]>; 发送时间: 2020年5月5日(星期二) 中午1:53 收件人: "shifeng1993/react-native-secharts"<[email protected]>; 抄送: "陈韵同"<[email protected]>; "Author"<[email protected]>; 主题: 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.

cyt68 avatar May 07 '20 05:05 cyt68

我用的 try catch

shiguo2021 avatar Aug 13 '20 06:08 shiguo2021

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

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 即可。

HoPGoldy avatar Dec 31 '20 06:12 HoPGoldy