在 vue 3 中使用 vue-chartjs:createElement 不是函数

using vue-chartjs in vue 3 : createElement is not a function(在 vue 3 中使用 vue-chartjs:createElement 不是函数)

本文介绍了在 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 不是函数

基础教程推荐