做测试的时候报错
index.js?bed3:161 [WDS] Errors while compiling. Reload prevented.
errors @ index.js?bed3:161
onmessage @ socket.js?57b2:41
EventTarget.dispatchEvent @ sockjs.js?3600:170
eval @ sockjs.js?3600:887
SockJS._transportMessage @ sockjs.js?3600:885
EventEmitter.emit @ sockjs.js?3600:86
WebSocketTransport.ws.onmessage @ sockjs.js?3600:2961
index.js?bed3:167 ./src/components/shopList
Module build failed: Error: ENOENT: no such file or directory, open 'D:\WorkSpaces\test_project\test_app\test_mt\src\components\shopList'
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/page/MSite/MSite.vue 49:0-45
检查发现组件注册引用了
报错:
检查配置文件也没什么问题 后来发现加上后缀名报错消失
import shopList from '@/components/shopList.vue'
换种方式引用 相对路径引用 也没问题
import shopList from '../../components/shopList'
再后面测试按照vue官方的命名方式把 shopList =》ShopList
报错也消失了 最奇怪的是我用了headerBar组件和shopList 一样的命名方式 只有shopList报错?
查了资料说是shopList 和ShopList 解析方式是一样的 所以目前还是不清楚是何原因??最后只能说要求自己按照官方命名方式来注册组件吧。。。
vue组件注册:https://cn.vuejs.org/v2/guide/components-registration.html
留个笔记 如果有大神知晓 不吝赐教 谢谢。
续更
项目重启后
import shopList from '@/components/shopList' 引入报错消失 猜测应该是vue内部加载判断组件的问题 再次提醒自己按照官方命名方式