搜尋

首頁  >  問答  >  主體

Vue 3中的元件導入

嗨,我正在嘗試在 Vue 3 中匯入一個元件。 這是我的元件結構:


#
+src
  +App.vue
  +components
    +Navbar.vue


#

在我的 App.vue 中我嘗試過:


#
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template>
<div>
<Navbar/>
</div>
</template>
<script>
import  Navbar  from './components/Navbar.vue';
</script>
這是我的 main.ts :



#
import { createApp } from 'vue'
import router from './router'

import mitt from 'mitt';
const emitter = mitt();

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue-3/dist/bootstrap-vue-3.css'
import BootstrapVue3 from 'bootstrap-vue-3'
import App from './App.vue'
const app = createApp(App)
app.use(router)
app.use(BootstrapVue3)
app.mount('#app')
app.config.globalProperties.emitter = emitter;


#

但我收到此錯誤:


#
Already included file name '/home/jip/Projects/snippedit/client/src/components/Navbar.vue' differs from file name '/home/jip/Projects/snippedit/client/src/components/navBar.vue' only in casing.
  The file is in the program because:
    Imported via './components/Navbar.vue' from file '/home/jip/Projects/snippedit/client/src/App.vue'
    Root file specified for compilation
    Root file specified for compilation


#

有誰知道這個問題的解決方法嗎? 提前致謝。

P粉564192131P粉564192131314 天前639

全部回覆(2)我來回復

  • P粉613735289

    P粉6137352892024-01-22 14:00:39

    如果您使用 vuter 擴展,請嘗試重新啟動/重新載入 vscode

    回覆
    0
  • P粉141925181

    P粉1419251812024-01-22 10:13:22

    這就是 App.vue 的樣子:

    
    
    sssccc

    回覆
    0
  • 取消回覆