简体   繁体   English

Vue 3 组件不导入其他 vue 组件

[英]Vue 3 components not importing other vue components

My Vue component navbar.vue does not import other components.我的 Vue 组件navbar.vue没有导入其他组件。
This is Vue 3 with the Option API.这是带有选项 API 的 Vue 3。
All of the components are imported by index.js in the component folder所有组件都由index.js在组件文件夹中导入

import navbar from '@/components/navbar.vue'
import btn from '@/components/btn.vue'

export {
  navbar,
  btn
}

This is the navbar.vue :这是navbar.vue

<template>
  <header class="navbar">
    <ul>
      <li>
        <router-link to="/">Home</router-link>
      </li>
      <li>
        <btn></btn>
      </li>
    </ul>
  </header>
</template>

<script>
import { btn } from '@/components'

export default {
  name: 'navbar',
  components: {
    btn
  }
}
</script>

This is the btn.vue components:这是btn.vue组件:

<template>
  <button class="btn" @click="$emit('click')">
    <slot/>
  </button>
</template>

<script>
export default {
  name: 'btn'
}
</script>

Your index.js exported navbar and btn .您的 index.js 导出navbarbtn And also you have already exported another component from navbar.vue in same file level.而且您已经在同一文件级别从navbar.vue导出了另一个组件。 So make a separate folder for navbar and btn or change the export name.因此,为navbarbtn创建一个单独的文件夹或更改导出名称。 I am new to frameworks.我是框架的新手。 Hope this will work.希望这会奏效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM