1、错误如下:

[Vue warn]: Unknown custom element: <line-chart> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

2、开始试了,检查自定义的组件名

<template>
    <div>
      // 四种效果是一样的
      <line-chart :chart-data="lineChartData" />
      <LineChart :chart-data="lineChartData" />
      <LineChart :chart-data="lineChartData"></LineChart>
      <line-chart :chart-data="lineChartData"></line-chart>
    </div>
</template>

<script>
    import LineChart from './components/LineChart'
    .....
    export default {
      name: 'DashboardAdmin',
      components: [
        LineChart
      ],
    }
</script>

3、Vue自定义组件,名称确实没有错误,但是还是找不到组件,最后发现在<script></script>中,发现{}被我写成了[]

修改后:
  components: {
    组件名
  }
修改前:
  components: [
    组件名
  ],

Logo

前往低代码交流专区

更多推荐