我在用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)

这是一个应用程序.显示我的图表的vue:

<template>
  <line-chart />
</template>

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

  name: "App",
  components: {
    LineChart
  }
};
</script>

这是图表.呈现折线图的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>

我用各种形式的数据try 过这一点,但显然,问题出在其他地方.

推荐答案

https://github.com/apertureless/vue-chartjs

Vue图表似乎还没有为vue3做好准备

兼容性

v1 later @legacy
    Vue.js 1.x
v2 later
    Vue.js 2.x

关于vue3的讨论:https://github.com/apertureless/vue-chartjs/issues/601

Vue.js相关问答推荐

如何用其他组件编译Vue模板?

正在try 访问vutify中v-select(ItemProps)的嵌套json值

Vutify-v-工具提示-不使用键盘轻击按钮显示

为什么发送 POST API 请求时主体对象没有react ?

为什么在 Vue2 中调用 this.$emit() 后 props 没有立即更新?

使用 nuxt.js 组件自动导入对性能不利吗?

Vuex store 在 Nuxt 的什么地方

我是否必须在 Vue 3 中使用 Composition API,还是仍然可以使用Vue 2的方式工作?

在组件上的 Vue 3 中获取 URL 查询参数

Vuetify v-select 组件宽度变化

在 SPA VueJS 中全局声明 mapState 和 mapMutations

如何使用 vue-resource 添加额外的标头来发布请求?

SassError:媒体查询表达式必须以(开头

VueJS 使用 prop 作为数据属性值

使用vue.js单击时如何获取按钮的值

触发子函数

基本 vue.js 2 和 vue-resource http 获取变量赋值

使用props向组件添加类名

在鼠标悬停时动态添加和删除类

Mapbox 事件监听器