0

正如标题所说,我的 Vue 环境有问题。尽管我的问题与此处的其他主题有相似之处,但我找不到适合我具体情况的解决方案。

<template>
  <div id="background">
    <Header />
    <Buttons />
    <Viewer />
    <SmartME />
  </div>
</template>

<script>
import Header from './components/Header.vue';
import Buttons from './components/Buttons.vue';
import Viewer from './components/Viewer.vue';

const SmartME = require('../../sources/SmartME').default;

export default {
  name: 'App',
  components: {
    SmartME,
    Header,
    Buttons,
    Viewer,
  },
};
</script>

<style>
  #background {
    background: lightgreen;
    margin: -8px;
  }
</style>

这是错误控制台的日志:

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

found in

---> <App> at src/App.vue
       <Root>

编辑:

请随时向我询问有关此问题的更多详细信息(例如屏幕截图和您可能认为对我有帮助的其他代码部分。

4

1 回答 1

1

您的错误与使用有关require。为什么你不像import上面的其他人那样使用它?

import SmartME from '../../sources/SmartME';

或者

import { default as SmartME } from '../../sources/SmartME';

取决于如何SmartME导出它的模块

于 2020-01-02T14:51:52.370 回答