vue-cli构建项目,在app.vue里面调用一个组件时报错,但在子页面当中却没问题,什么原因?

我用vue-cli构建了一个项目,只有在app.vue里调用组件时就报错,但在子页面当中却能正常调用,到底是什么原因?
下面是错误报告:

ERROR in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 
Module not found: Error: Can't resolve 'components/navList.vue' in 'C:\Users\Mr.Mo\oneapp\pt\src'
 @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue 3:0-45 
 @ ./src/App.vue 
 @ ./src/main.js 
 @ multi ./build/dev-client ./src/main.js

另外我在npm终端看到这个错误提示:

 This dependency was not found:

* components/navList.vue in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue

To install it, you can run: npm install --save components/navList.vue

这是app.vue的部分代码:

<script>
import navList from 'components/navList.vue'
export default {
  name: 'app',
  data:function(){
    return {
     items:[
       {text:'asd',href:'#'}
      ]
    }
  },
  components:{
    'nav-list':navList
  }
}
</script>
阅读 6.3k
评论
    4 个回答
    • 1.9k

    import navList from 'components/navList.vue' 这个的路径错了哦。没有猜错的话你试试这么写,import navList from './components/navList.vue'

      相似问题
      推荐文章