浏览器中会出现这种类型的报错
[Vue warn]: Failed to mount component: template or render function not defined.
found in
---> <Index> at src/views/car/allcar/index.vue
<AppMain> at src/layout/components/AppMain.vue
<ElScrollbar>
<Layout> at src/layout/index.vue
<App> at src/App.vue
<Root>
经过查资料,反复查证回想改了什么,发现是因为昨天在在哪个页面组件目录(src\views\组件目录)里面新建了个index.js,so,现在这个组件目录下有一个index.vue和index.js,导致路由配置表里面引入组件的时候引入到了index.js没有引入到组件导致报错。
解决方法检查一下是不是根目录没有template标签,直接写view就会报错,文件名字不能一样
同名的文件最为容易报错尽量避免这个问题,出现了会导致加载路由失败渲染失败
1、index.js文件不要放在组件目录下或者改名字,2、路由表配置指定后缀,比如:component: () => import('@/views/subfile/index.vue') 就可以了。3、要在文件夹下要添加内容例如加入template