VUE-CHARTJS可以从VUE导入数据
在编译了我的VUE 2项目之后,我会遇到此错误:
Failed to compile.
./node_modules/vue-chartjs/dist/index.js 85:11-26
"export 'defineComponent' was not found in 'vue'
上面的文件中导致此行为的行是:
import { defineComponent, shallowRef, ref, watch, onMounted, onBeforeUnmount, toRaw, h, isProxy } from 'vue';
所有这些导入都会导致相同的错误。在我将Vue-Chartjs从3.5.1版本升级到版本4.1.1(在完美工作之前)之后,就会发生这种情况。我正在寻找可能导致这一目标的想法。
使用的依赖性版本是:
- "chart.js": "^3.8.0"
- "vue": "^2.6.14"
- "vue-chartjs": "^4.1.1"
不幸的是,我无法提供摘要。这仅在工作中使用的项目上发生。如果我在一个干净的项目中尝试此操作,它将完美编译。关于VUE的信息,互联网几乎是无效的,因此我只是在寻找任何想法。
您能想到的任何事情都可能导致这一点,请分享。即使是最愚蠢的想法也可能有帮助,我已经在互联网上搜寻了几天,但找不到任何东西。这变得非常令人沮丧,我要做的就是升级图表。
I get this error after compiling my Vue 2 project:
Failed to compile.
./node_modules/vue-chartjs/dist/index.js 85:11-26
"export 'defineComponent' was not found in 'vue'
The line in the file above that is causing this behavior is:
import { defineComponent, shallowRef, ref, watch, onMounted, onBeforeUnmount, toRaw, h, isProxy } from 'vue';
All of these imports cause the same error. This happens after I upgrade vue-chartjs from version 3.5.1 to version 4.1.1 (before it works perfectly). I'm looking for ideas on what might be causing this.
The versions of used dependencies are:
- "chart.js": "^3.8.0"
- "vue": "^2.6.14"
- "vue-chartjs": "^4.1.1"
Unfortunately, I cannot provide a snippet. This happens only on a project which is in use at work. If I try this on a clean project, it compiles perfectly. The Internet is almost void in regard to information on Vue, so I'm just looking for any idea.
Anything you can think of that could cause this, please share. Even the dumbest idea may help, I've been scouring the Internet for days and I can't find anything. This is getting super frustrating, all I wanted to do was upgrade chart.js and it's taking me days, lol.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想您正在尝试像这样导入Lib:
这对您不起作用,因为您使用了VUE2。要将VUE包装器与Vue2一起使用,您需要从
“ Vue-Chartjs/legacy”
中导入。在这里,他们支持VUE V2,然后您的应用程序应该可以汇总。正确为您导入:
从他们的
I guess you are trying to import the lib like so:
This won't work for you since you are using Vue2. To use the Vue wrapper with Vue2 you will need to import from
'vue-chartjs/legacy'
. In here they have support for Vue V2 and then your application should compile just fine.Correct import for you:
Comming from their readme
此错误通常来自您使用VUE3特定版本的事实。如下所述:“ export'default'(导入为'vue
'
vue-chartjs
的页面,我们可以看到v4.0.0
迁移到VUE3的变化发生了破坏: https://github.com/apertureless/vue-chartjs/releases/tag/tag/tag/v4.0.0.0/Vue-chartjs/Releases/tag/v4.0.0 引起此类问题。
This error is usually coming from the fact that you're using a Vue3 specific version. As explained here: "export 'default' (imported as 'Vue') was not found in 'vue'
Checking the releases page of
vue-chartjs
, we can see thatv4.0.0
had a breaking change of migrating to Vue3: https://github.com/apertureless/vue-chartjs/releases/tag/v4.0.0Hence why the v4 is causing such problem. Stay at
v3.5.1
(22 august 2020) or below if you're stuck with a Vue2 usage.