我将 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) 我正在尝试将回调从 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)