javascript - vue-cli构建项目,在app.vue里面调用一个组件时报错,但在子页面当中却没问题,什么原因?
本文介绍了javascript - 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>
解决方案
import navList from 'components/navList.vue'
这个的路径错了哦。没有猜错的话你试试这么写,import navList from './components/navList.vue'
这篇关于javascript - vue-cli构建项目,在app.vue里面调用一个组件时报错,但在子页面当中却没问题,什么原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文