gpt4 book ai didi

vue.js - 在 vue 3 : createElement is not a function 中使用 vue-chartjs

转载 作者:行者123 更新时间:2023-12-04 11:06:04 24 4
gpt4 key购买 nike

我正在使用 Vue.js 3,但由于此错误,我无法使用 Vue-chartjs 制作图表:

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:
<template>
<line-chart />
</template>

<script>
import LineChart from "./components/Chart";
export default {

name: "App",
components: {
LineChart
}
};
</script>
这是呈现折线图的 Chart.vue:
<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 生态系统变得更加完整?

最佳答案

https://github.com/apertureless/vue-chartjs
Vue Charts 似乎还没有为 vue3 做好准备
兼容性

v1 later @legacy
Vue.js 1.x
v2 later
Vue.js 2.x
关于vue3的讨论在这里: https://github.com/apertureless/vue-chartjs/issues/601
在这里: https://github.com/apertureless/vue-chartjs/issues/637

关于vue.js - 在 vue 3 : createElement is not a function 中使用 vue-chartjs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64114215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com