zrender
zrender copied to clipboard
用v5.x 的vue工程, npm run build 出来的页面,访问出错!
vue环境中使用 "zrender": "^5.1.1", 开发状态 npm run serve 运行一切正常 , 但 build 出来 运行 ,浏览器就报错了。 如果是v4.x ,就没有这个问题,不知是什么原因,求解决。 Error: Renderer 'undefined' is not imported. Please import it first. at new t (chunk-1cddc2cc.2efeabff.js:1) at Object.Xt (chunk-1cddc2cc.2efeabff.js:1) at a.init (chunk-1cddc2cc.2efeabff.js:1) at a.mounted (chunk-1cddc2cc.2efeabff.js:1) at it (chunk-vendors.82dca4fd.js:7) at zn (chunk-vendors.82dca4fd.js:7) at Object.insert (chunk-vendors.82dca4fd.js:7) at $ (chunk-vendors.82dca4fd.js:7) at a.patch (chunk-vendors.82dca4fd.js:7) at a.Ln.e._update (chunk-vendors.82dca4fd.js:7)
import * as zrender from "zrender" import CanvasPainter from "zrender/lib/canvas/Painter" zrender.registerPainter("canvas",CanvasPainter)
需要 registerPainter 才可以正常用!!!
改成import * as zrender from "zrender/dist/zrender",或者在webpack里配置alias,zrender: ''zrender/dist/zrender"
我在vite工程中引用也遇上了这个问题
import * as zrender from 'zrender/src/zrender'; zrender.init就报错 zrender.ts:112 Uncaught (in promise) Error: Renderer 'undefined' is not imported. Please import it first.
import * as zrender from "zrender" import CanvasPainter from "zrender/lib/canvas/Painter" zrender.registerPainter("canvas",CanvasPainter)
需要 registerPainter 才可以正常用!!!
nuxt 用,不起作用,我dev模式可以,发布也不可以。
import * as zrender from "zrender" import CanvasPainter from "zrender/lib/canvas/Painter" zrender.registerPainter("canvas",CanvasPainter)
需要 registerPainter 才可以正常用!!!
"zrender": "^5.4.0" 有办法解决么,大佬。
同样的问题,添加
import * as zrender from "zrender/dist/zrender";
解决
同样的问题,添加
import * as zrender from "zrender/dist/zrender";
解决
还有个小问题,我控制一个地方,几个不同echarts切换,正确做法是替换不同option么?还是弄多个div,如果多个div,有默认隐藏的,渲染的大小就会不对。
v5.4 同样的问题,registerPainter 后解决,期待文档及时更新
如果使用按需加载,需要使用 registerPainter 注册绘制类型,否则打包后会报错
import { init, Polyline, registerPainter } from 'zrender'
import CanvasPainter from 'zrender/lib/canvas/Painter'
registerPainter('canvas', CanvasPainter)