I built a project using vue-cli. An error is reported only when calling the component in app.vue, but it can be called normally in the sub-page. What is the reason?
The following is the error report:
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
In addition, I saw this error message in the npm terminal:
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
This is part of the code of 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'
This happened to me yesterday when I was writing. .
I searched for a long time and didn’t find out what was going on. . Because I am convinced that nothing is wrong. .
Then I closed the process and restarted it, and the compilation was successful. . Cheating. . The error is the same as yours. Except the path. .
You need to write something in front of the project directory. They are all relative paths. If it is in the node_modules directory, you can quote it directly
as