javascript - When building a project with vue-cli, an error occurs when calling a component in app.vue, but there is no problem in the subpage. What is the reason?
PHP中文网
PHP中文网 2017-05-19 10:33:25
0
3
639

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:

PHP中文网
PHP中文网

认证0级讲师

reply all (3)
过去多啦不再A梦

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

    phpcn_u1582

    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. .

      刘奇
      './components/navList.vue'

      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

      import "vue"
        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!