今天npm run dev的時候,有個頁面報錯,提示[Vue warn]: Failed to mount component: template or render function not defined.
昨天還好好的,今天就報錯了,也沒改啥,
經過查資料,反復查證回想改了什么,發現是因為昨天在在哪個頁面組件目錄(src\views\組件目錄)里面新建了個index.js,so,現在這個組件目錄下有一個index.vue和index.js,導致路由配置表里面引入組件的時候引入到了index.js沒有引入到組件導致報錯,
路由表配置:component: () => import('@/views/subfile/index') 這里沒有指定是index,所以導致找到了index.js,
解決辦法:1、index.js檔案不要放在組件目錄下或者改名字,2、路由表配置指定后綴,比如:component: () => import('@/views/subfile/index.vue') 就可以了,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/521883.html
標籤:其他
