using vue-chartjs in vue 3 : createElement is not a function(在 vue 3 中使用 vue-chartjs:createElement 不是函数)
问题描述
我正在使用 Vue.js 3,由于这个错误,我无法使用 Vue-chartjs 制作图表:
I'm using Vue.js 3 and I can't make a chart with Vue-chartjs because of this error:
Uncaught TypeError: createElement is not a function
at Proxy.render (BaseCharts.js?86fc:8)
at renderComponentRoot (runtime-core.esm-bundler.js?5c40:673)
at componentEffect (runtime-core.esm-bundler.js?5c40:4475)
at reactiveEffect (reactivity.esm-bundler.js?a1e9:42)
at effect (reactivity.esm-bundler.js?a1e9:17)
at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4458)
at mountComponent (runtime-core.esm-bundler.js?5c40:4416)
at processComponent (runtime-core.esm-bundler.js?5c40:4376)
at patch (runtime-core.esm-bundler.js?5c40:3991)
at mountChildren (runtime-core.esm-bundler.js?5c40:4180)
这是显示我的图表的 App.vue:
this is App.vue that displays my chart:
<template>
<line-chart />
</template>
<script>
import LineChart from "./components/Chart";
export default {
name: "App",
components: {
LineChart
}
};
</script>
这是渲染折线图的 Chart.vue:
and this is Chart.vue that renders a line chart :
<script>
import { Line } from "vue-chartjs";
export default {
extends: Line,
data: () => ({
chartdata: {
labels: ["January", "February"],
datasets: [
{
label: "Data One",
backgroundColor: "#f87979",
data: [40, 20]
}
]
},
options: {
responsive: true,
maintainAspectRatio: false
}
}),
mounted() {
this.renderChart(this.chartdata, this.options);
}
};
</script>
我已经尝试过使用各种形式的数据,但显然,问题出在其他地方.是否必须等待 vue.js 3 生态系统变得更加完整?
I have tried this with various forms of data, but apparently, the problem is elsewhere. Do I have to wait for the vue.js 3 ecosystem to become more complete?
推荐答案
https://github.com/无孔径/vue-chartjs
Vue Charts 似乎还没有为 vue3 做好准备
Vue Charts does not seem to be ready for vue3
兼容性
v1 later @legacy
Vue.js 1.x
v2 later
Vue.js 2.x
在这里讨论vue3:https://github.com/apertureless/vue-chartjs/问题/601在这里:https://github.com/apertureless/vue-chartjs/issues/637
Discussion about vue3 here: https://github.com/apertureless/vue-chartjs/issues/601 and here: https://github.com/apertureless/vue-chartjs/issues/637
这篇关于在 vue 3 中使用 vue-chartjs:createElement 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 vue 3 中使用 vue-chartjs:createElement 不是函数
基础教程推荐
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 动态更新多个选择框 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01