Open jhxxs opened 2 years ago
addEventListener报错是啥原因啊?我这边也是这个报错。还有另一个报错:Cannot read property 'config' of undefined
plugins: [ [path.resolve(__dirname, "./plugin/echarts.ts") ]多了一个"[",有时间改一下。
plugins: [ [path.resolve(__dirname, "./plugin/echarts.ts") ]多了一个"[",有时间改一下。
已修复
使用图表的拖拽事件时候,会有报错。你解决过吗 ![Uploading screenshot-20221124-131905.png…]()
单独做个npm包有点麻烦,所以这里做个记录,希望大佬不要介意,有需要的自取:
首先去Echarts在线定制页面构建自己需要的
echarts.min.js
,下载后放到项目的config
目录下,我试了使用最新的5.3.2
版本正常运行在项目的
config
目录下新建echarts.ts
自定义taro插件(保证和自己下载的echarts.min.js
在同一目录):export default (ctx: IPluginContext) => { // 接下来使用 ctx 的时候就能获得智能提示了 ctx.onBuildStart(() => { /*
echarts-taro3-react
使用的echarts
文件 / const nodeModuleEchartsPath = path.join( ctx.paths.nodeModulesPath, "/echarts-taro3-react/lib/ec-canvas/echarts.js" ) /* 自己从echarts官网自定义构建的包 / const customBuildEchartsPath = path.resolve(__dirname, "./echarts.min.js") const text = fs.readFileSync(customBuildEchartsPath).toString() // 修复可能出现addEventListener
调用报错 const str = text.replace( /(EventListener)((\w{1}),(\w{1}),(\w{1}))/g, (...args) => { const [, f, a, b, c] = args return${f}?.(${a},${b},${c})
} ) // 覆盖node_module使用的包 fs.writeFileSync(nodeModuleEchartsPath, str) }) }