Uncaught (in promise) TypeError: this.renderChart is not a function at Proxy.mounted

编程入门 行业动态 更新时间:2024-10-07 12:21:46

Uncaught (in promise) <a href=https://www.elefans.com/category/jswz/34/1771446.html style=TypeError: this.renderChart is not a function at Proxy.mounted"/>

Uncaught (in promise) TypeError: this.renderChart is not a function at Proxy.mounted

错一个

ChartBar.vue?05e0:36

   Uncaught (in promise) TypeError: this.renderChart is not a function
at Proxy.mounted (ChartBar.vue?05e0:36:1)
at eval (runtime-core.esm-bundler.js?d2dd:2738:1)
at callWithErrorHandling (runtime-core.esm-bundler.js?d2dd:157:1)
at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?d2dd:166:1)
at hook.__weh.hook.__weh (runtime-core.esm-bundler.js?d2dd:2713:1)
at flushPostFlushCbs (runtime-core.esm-bundler.js?d2dd:343:1)
at flushJobs (runtime-core.esm-bundler.js?d2dd:397:1)

错误二

   [Vue warn]: Unhandled error during execution of mounted hook 

我找不到这两个错误的解决方案,我将不胜感激

图表栏.vue

<template>
  <Bar id="my-chart-id" :options="chartOptions" :data="chartData" />
</template>

<script>
import { Bar } from "vue-chartjs";

import {
  Chart as ChartJS, 
  Title,
  Tooltip,
  Legend,
  BarElement,
  CategoryScale,
  LinearScale,
} from "chart.js";
//import { LibraryTemplatePlugin } from "webpack";

ChartJS.register(
  Title,
  Tooltip,
  Legend,
  BarElement,
  CategoryScale,
  LinearScale
);

export default {
  name: "ChartBar",
  components: { Bar },
  props: {
    chartOptions: { type: Object, default: null },
    chartData: { type: Object, default: null },
  },
  mounted() {
    this.renderChart(this.chartData, this.chartOptions);
  },
};
</script>

仪表板.vue html

<div>
          <ChartBar
            v-if="loaded"
            :chart-data="chartData"
            :chart-options="chartOptions"
          ></ChartBar>
        </div>

剧本

<script>
import RacentCandidateRow2 from "../components/RacentCandidateRow copy.vue";
import ChartLine from "@/components/ChartLine.vue";
import ChartBar from "@/components/ChartBar.vue";

import axios from "axios";

import {
  Chart as ChartJS,
  Title,
  Tooltip,
  Legend,
  BarElement,
  CategoryScale,
  LinearScale,
} from "chart.js";
//import { LibraryTemplatePlugin } from "webpack";

ChartJS.register(
  Title,
  Tooltip,
  Legend,
  BarElement,
  CategoryScale,
  LinearScale
);

export default {
  name: "DashboardView",
  components: {
    RacentCandidateRow2,
    ChartBar,
    ChartLine,
  },

  data() {
    return {
      ChartBar: [],
      chartData: { type: Array },
      chartOptions: { type: Array },
      loaded: false,
    };
  },

  async mounted() {
    this.loaded = false;
    await axios
      .get("/api/dashboard")
      .then((response) => {
        const ChartBarName = (this.ChartBar = response.data.Funnel_Name);
        const ChartBarNumber = (this.ChartBar = response.data.Funnel_Number);
        this.loaded = true;
        this.chartData = {
          labels: ChartBarName,
          datasets: [
            {
              data: ChartBarNumber,
              backgroundColor: ["rgba(51, 97, 255)", "rgba(51, 97, 255)"],
              borderColor: ["rgba(51, 97, 255)"],
              borderWidth: 1,
              borderRadius: 10,
            },
          ],
        };

        this.chartOptions = {
          responsive: true,
          scales: {
            y: {
              beginAtZero: true,
              grid: {
                display: false,
              },
              border: {
                display: false,
              },
            },
            x: {
              ticks: {
                font: {
                  size: 13,
                },
              },
              grid: {
                display: false,
              },
              border: {
                display: false,
              },
            },
          },
          plugins: {
            legend: {
              display: false,
            },
          },
        };
        this.loaded = true;
      })

      .catch((error) => {
        console.error(error);
      });
  },
};
</script>
回答如下:

更多推荐

Uncaught (in promise) TypeError: this.renderChart is not a function at Proxy.mou

本文发布于:2024-05-13 16:52:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1760166.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:TypeError   promise   Uncaught   renderChart   mounted

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!