[英]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 导出
navbar
和btn
。 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.因此,为
navbar
和btn
创建一个单独的文件夹或更改导出名称。 I am new to frameworks.我是框架的新手。 Hope this will work.
希望这会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.