Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'ToolItem' of undefined #1181

Open
aov2005 opened this issue Jul 19, 2021 · 9 comments
Open

Cannot read property 'ToolItem' of undefined #1181

aov2005 opened this issue Jul 19, 2021 · 9 comments
Labels
type: bug 缺陷 Defects and unexpected behaviors

Comments

@aov2005
Copy link

aov2005 commented Jul 19, 2021

Expected Behavior

可以正常使用vue节点

Current Behavior

单独使用x6的时候没这个报错,引用x6-vue-shape的时候报这个错了

Possible Solution

Steps To Reproduce

  1. yarn add @antv/x6 @antv/x6-vue-shape
  2. import { Graph } from "@antv/x6";
  3. import "@antv/x6-vue-shape";
Error Message & Stack Trace

client.ts:13 [vite] connecting...
client.ts:43 [vite] connected.
vue-i18n.esm-bundler.js:46 You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
initFeatureFlags @ vue-i18n.esm-bundler.js:46
(anonymous) @ vue-i18n.esm-bundler.js:2216
index.js:15 antdv installed
TypeError: Cannot read property 'ToolItem' of undefined
    at button.ts:10
Promise.catch (async)
extractComponentsGuards @ vue-router.esm-bundler.js:2021
(anonymous) @ vue-router.esm-bundler.js:3082
Promise.then (async)
navigate @ vue-router.esm-bundler.js:3077
pushWithRedirect @ vue-router.esm-bundler.js:2972
push @ vue-router.esm-bundler.js:2911
install @ vue-router.esm-bundler.js:3289
use @ runtime-core.esm-bundler.js:4001
default @ install.ts:23
(anonymous) @ main.ts:11
vue-router.esm-bundler.js:72 [Vue Router warn]: Unexpected error when starting the router: Error: Couldn't resolve component "default" at "/data-exploration/user"
    at vue-router.esm-bundler.js:2025
warn @ vue-router.esm-bundler.js:72
(anonymous) @ vue-router.esm-bundler.js:3291
Promise.catch (async)
install @ vue-router.esm-bundler.js:3289
use @ runtime-core.esm-bundler.js:4001
default @ install.ts:23
(anonymous) @ main.ts:11

Additional Context

Your Environment

  • x6: 1.24.5
  • OS: macOS 11.4
  • Browser: edge 90
@aov2005 aov2005 added the type: bug 缺陷 Defects and unexpected behaviors label Jul 19, 2021
@x6-bot
Copy link
Contributor

x6-bot bot commented Jul 19, 2021

👋 @aov2005

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@jtsang4
Copy link
Member

jtsang4 commented Jul 23, 2021

是否使用 vite,如果是的话有一个相关 issue 以及绕开的办法:vitejs/vite#3413

@aov2005 aov2005 closed this as completed Jul 26, 2021
@mmrxia
Copy link

mmrxia commented Nov 22, 2021

package.json

"resolutions": {
    "vite": "2.2.4"
},

@yesmeck
Copy link

yesmeck commented Nov 24, 2021

为什么不在 X6 的代码里修复呢?这里的 namespace 不是 ES 的标准,所以导致用 ES modules 的方式 import ToolItem 时报错了。

@aov2005
Copy link
Author

aov2005 commented Nov 29, 2021

vitejs/vite#3413 (comment)

直接引用构建好的就好了

@jtsang4
Copy link
Member

jtsang4 commented Apr 26, 2022

This issue still exist in vite(vitejs/vite#3413) and need to be fixed.

@jtsang4 jtsang4 reopened this Apr 26, 2022
@NewByVector NewByVector added type: feature 新功能 Feature/enhancement requests and removed type: bug 缺陷 Defects and unexpected behaviors labels May 13, 2022
@TLovers
Copy link

TLovers commented May 30, 2022

目前这个问题还是有 的亏来搜了issue

@Fnxxxxo
Copy link

Fnxxxxo commented May 31, 2022

是否使用 vite,如果是的话有一个相关 issue 以及绕开的办法:vitejs/vite#3413

需要继承button实现,这个办法会导致import { Button } from '@antv/x6/es/registry/tool/button';的写法报错,这个问题还是绕不开的。

lloydzhou added a commit to lloydzhou/openGuass-workflow-vue3-test that referenced this issue Aug 23, 2022
@NewByVector NewByVector added type: bug 缺陷 Defects and unexpected behaviors and removed type: feature 新功能 Feature/enhancement requests labels Jan 29, 2023
@pot-mot
Copy link

pot-mot commented Jan 12, 2024

现在这个报错有解决方案或者替换方案了吗
我使用 vite 5.0.10 vue 3.3.4 尝试 define Button 出现了这个问题

import {Button} from '@antv/x6/es/registry/tool/button'
TypeError: Cannot read properties of undefined (reading 'ToolItem')

目前临时的解决办法就是不使用 define 而使用解构语法 + 基础属性替代继承,然后强行在 attrs 里塞了个 type 进行判断,除了 remove(name) 不太方便其他都还行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 缺陷 Defects and unexpected behaviors
Projects
None yet
Development

No branches or pull requests

8 participants