Fixed #955 - Chart.js gives Chart is not a contructor

pull/1196/head^2
mertsincan 2021-05-05 12:34:24 +03:00
parent fb3e7136ab
commit b328ea952c
1 changed files with 9 additions and 7 deletions

View File

@ -5,8 +5,6 @@
</template> </template>
<script> <script>
import * as Chart from 'chart.js';
export default { export default {
emits: ['select'], emits: ['select'],
props: { props: {
@ -45,10 +43,14 @@ export default {
}, },
methods: { methods: {
initChart() { initChart() {
this.chart = new Chart(this.$refs.canvas, { import('chart.js').then((module) => {
type: this.type, if (module && module.default) {
data: this.data, this.chart = new module.default(this.$refs.canvas, {
options: this.options type: this.type,
data: this.data,
options: this.options
});
}
}); });
}, },
getCanvas() { getCanvas() {
@ -91,4 +93,4 @@ export default {
.p-chart { .p-chart {
position: relative; position: relative;
} }
</style> </style>