vite项目下,安装引入@antv/x6-vue-shape会报错

只安装@antv/x6正常,安装x6-vue-shape后会报错
1、安装@antv/x6-vue-shape
2、import { Graph } from “@antv/x6”;
3、报错button.ts:10
Uncaught TypeError: Cannot read properties of undefined (reading 'ToolItem');

版本

"@antv/x6": "^1.30.0",
"@antv/x6-vue-shape": "^1.3.1",

解决方案

// vite.config.js
  resolve: {
    alias: [
      {
        find: '@antv/x6',
        replacement: '@antv/x6/lib'
       },
      {
         find: '@antv/x6-vue-shape',
         replacement: '@antv/x6-vue-shape/lib',
       },
   ]
 },

replacement: @antv/x6/lib 不起作用,请设置为 @antv/x6/dist/x6.js,否则 build 后会产生错误。

注:vite 问题可以参考 https://github.com/vitejs/vite/issues/3413

Logo

前往低代码交流专区

更多推荐