解决vue报错Failed to mount component:template or render function not defined

[Vue warn]: Failed to mount component: template or render function not defined.

the reason:

vue-loader在引入时把index.js当做了入口,而不是index.vue
1. error page directory structure:
- Disease (文件夹)
   - disease.js (js -- 将script内容拿出来放到单独的js中)
   - index.vue (页面文件)

Here Insert Picture Description

2. The error page structure
<template>
    <div class="content">内容</div>
</template>

<script>
    import index from './index.js';
    export default index;
</script>

<style lang="less" scoped>
    @import "../main/index.less"
</style>
3. error router
const Disease = () => import('@/pages/Disease/index');

const router = new Router({
    {
      path: '/Disease',
      name: 'Disease',
      component: Disease,
      meta: { requireAuth: true },
    },
});
export default router;
4. Solution

The solution is simple, add index.vue introduction assembly on it.

const Disease = () => import('@/pages/disease/index.vue')
Published 71 original articles · won praise 68 · views 50000 +

Guess you like

Origin blog.csdn.net/qq_37896578/article/details/104969974