小编Mik*_*ike的帖子

使用 Vue 3 渲染两次 Apex 图表的问题

我将 Apex Charts 与 Vue 3 一起使用。当图表渲染(绘制)时,它会渲染两次。奇怪的是,当我调整大小或移动浏览器窗口时,第二个图表就会从 DOM 中删除。我还仔细检查了我的 Vue 组件,以确保我没有两次导入此图表组件。

<template>

<apexchart
  width="500"
  height="400"
  type="bar"
  :options="chartOptions"
  :series="series">
</apexchart>

</template>

<script>

import VueApexCharts from "vue3-apexcharts";

export default {
    name: 'ChartExample',
    components: {
        apexchart: VueApexCharts
    },
    data() {
        return {
            chartOptions: {
                chart: {
                    id: "vuechart-example",
                },
                xaxis: {
                    // categories loaded here
                },
            },
            series: [
                // data loaded here
            ],
        };
    },
    mounted() {
        this.series = [
            {
            name: 'precip',
            data: [1,2,3,4,5],
            }
        ];
        this.chartOptions.xaxis = {
            categories: [1,2,3,4,5], …
Run Code Online (Sandbox Code Playgroud)

vue.js apexcharts vuejs3

2
推荐指数
1
解决办法
3474
查看次数

如何从 javascript 类 js 发送回调

我正在尝试将回调从 javascript 类发送到其对象。我还没有取得任何进展。

class MyClass {
    constructor(param1, param2) {
      // trigger the callback
      this.callback();
   }
}

obj = MyClass({
    parameter1: 'test',
    parameter2: 'test',
    callback() {
        alert('callback received');
    }
});
Run Code Online (Sandbox Code Playgroud)

javascript oop class

0
推荐指数
1
解决办法
223
查看次数

标签 统计

apexcharts ×1

class ×1

javascript ×1

oop ×1

vue.js ×1

vuejs3 ×1