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

查看:165
本文介绍了在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/apertureless/vue-chartjs

Vue图表似乎尚未准备好用于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/issues/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不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆