antvis / X6

🚀 JavaScript diagramming library that uses SVG and HTML for rendering.
https://x6.antv.antgroup.com
MIT License
5.62k stars 1.68k forks source link

antv x6初始化画布报错Uncaught TypeError: Class constructor Ph cannot be invoked without 'new' #4342

Open GYJ11 opened 2 months ago

GYJ11 commented 2 months ago

问题描述

在html文件中使用script标签引入https://cdnjs.cloudflare.com/ajax/libs/antv-x6/2.0.0/index.js,然后调用new X6.Graph,结果控制台报错Uncaught TypeError: Class constructor Ph cannot be invoked without 'new',画布也没加载出来

重现链接

见问题描述

重现步骤

见问题描述

预期行为

用cdn的方式引入antv x6并初始化画布不会出现报错,能够正常加载出画布

平台

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

x6-bot[bot] commented 2 months ago

👋 @GYJ11

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.

XueMeijing commented 2 months ago

用新点的版本可以

<div id="root" style="width: 600px;height: 600px;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/antv-x6/2.18.1/index.js"></script>
<script>
  const graph = new X6.Graph({
    container: document.querySelector('#root'),
    grid: true
  })
  console.log('X6', X6)
  console.log('graph', graph)
</script>

image