【发布时间】:2020-05-26 17:13:22
【问题描述】:
我已经制作了一个 Vue CLI 项目,然后开始制作我的项目。
我制作了以下名为Navigation.vue的组件:
<template>
<nav>
<div class="nav_container">
<a href="https://www.metrici.ro/" target="_blank" class="logo"></a>
<ul>
<li><router-link to="/home">Home</router-link></li>
<li class="dropdown">
<a class="touch"
>Network Settings <i class="fas fa-angle-down"></i
><i class="fas fa-angle-up"></i
></a>
<div class="dropdown-content">
<router-link to="/dhcpIP">DHCP IP</router-link>
<router-link to="/staticIP">Static IP</router-link>
</div>
</li>
<!-- <li><router-link to="/files">Import/Export Files</router-link></li> -->
<li><router-link to="/update">Update</router-link></li>
</ul>
</div>
</nav>
</template>
<script>
export default {
name: 'Navigation',
}
</script>
<style scoped>
/* Some style */
</style>
然后我把它导入到App.vue:
<template>
<div id="app">
<Navigation />
<router-view />
</div>
</template>
<script>
import Navigation from "./components/Navigation.vue";
</script>
<style scoped>
/* Some style */
</style>
最后我有main.js,我没有修改:
import App from './App.vue'
import router from './router'
Vue.config.productionTip = false
new Vue({
router,
render: h => h(App)
}).$mount('#app')
我收到以下错误:
ERROR Failed to compile with 1 errors 8:10:25 PM
error in ./src/App.vue
Module Error (from ./node_modules/eslint-loader/index.js):
\App.vue
9:8 error 'Navigation' is defined but never used no-unused-vars
该组件已明确使用,但我收到该错误。我不明白为什么。
【问题讨论】:
-
您没有使用您正在导入的
Navigation变量。您需要将其用作组件。更多细节在这里:vuejs.org/v2/guide/…