为什么我的vue/cli项目在router内导入home却不能找到模块?
以下报错:
ERROR Failed to compile with 1 errors 09:10:59
This dependency was not found:
- src/components/pages/home in ./src/router/index.js
To install it, you can run: npm install --save src/components/pages/home
之前还显示下面报错:
- ../components/pages/home in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/components/pages/index.vue
下面src/router代码:
import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/components/pages/index'
import Home from 'src/components/pages/home'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
name: 'Index',
component: Index,
children:[
{
path:'/home',
components:Home
}
]
}
]
})
下面src/components/pages/home.vue文件内代码:
<template lang="html">
<div>
主界面
</div>
</template>
<script>
export default{
name:"home"
}
</script>
<style lang="css">
</style>
下面是我想放置home组件的src/components/pages/index.vue内代码:
```javascript
<template lang="html">
<div class="index">
<ul>
<li>
<img src="~@/assets/logo2.jpg" alt="">
</li>
<li>
歌手
</li>
<li>
榜单
</li>
<li>
我的
</li>
<li>
搜索
</li>
</ul>
<router-view />
</div>
</template>
<script>
export default{
}
</script>
<style scoped>
.index img{
width:50px;
height:50px;
}
.index ul{
display:flex;
height:50px;
line-height:50px;
background:#f9f9f9;
}
.index li{
flex:1;
text-align:center;
list-style-type: none;
}
.index ul li a{
font-size:16px;
color:#999;
}
</style>
```