先上问题:
SyntaxError: The requested module '/node_modules/.vite/deps/zrender.js?v=bf83ea43' does not provide an export named 'default'
原来我的引用是这么写的:import zrender from ‘zrender’
两种解决方法:
第一种:
import { defineComponent ,ref, onMounted,getCurrentInstance} from 'vue';
import { init, Rect, Line, Text, Group ,Circle} from 'zrender';
zrenderInit() {
const Obj2 = document.getElementById('canvas1'); //zrender取元素
const domOptions = { width: 500, height: 500 };
const zRenderDom = init(Obj2 , domOptions);
drawCircle();
zRenderDom.add(group);
}
第二种:
import * as zrender from 'zrender'
init() {
zr = zrender.init(document.getElementById('zrender-canvas'))
group = new zrender.Group()
drawCircle()
zr.add(this.group)
},