我正试图在我的App.vue中显示来自Charts.vue的特定图表,下面是我试图实现的目标:
Charts.vue
<template>
<div class="chart-container">
<canvas :ref="`chart${chartId}`"></canvas>
</div>
</template>
<script>
export default {
props: {
chartId: {
type: String,
required: true
}
}
....
}
</script>App.vue
<template>
<div class="content-1">
<chart :chartId="1" /> <-- Here i want to display my chart 1
</div>
....
<div class="content-8">
<chart :chartId="8" /> <-- Here i want to display my chart 2
</div>
</template>
<script>
import chart from './Charts'
export default{
name: 'App',
component: {charts}
....
}没有显示任何内容,并且我在控制台中得到了以下错误:

但是,假设我在<canvas ref="chart1"></canvas>模板中声明为Charts.vue,然后在Charts.vue模板中使用<charts/>,则显示图表。
请帮助我解决这个问题。
发布于 2021-01-05 12:32:53
这不只是一个错误吗?-您正在导入“图表”,但使用它作为“图表”。
https://stackoverflow.com/questions/65573051
复制相似问题