search

Home  >  Q&A  >  body text

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?

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>
PHP中文网PHP中文网2820 days ago719

reply all(3)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:35:25

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

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-19 10:35:25

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

    reply
    0
  • 怪我咯

    怪我咯2017-05-19 10:35:25

    './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"

    reply
    0
  • Cancelreply