解决vue报错Failed to mount component
废话不多说,放图:
我本次开发项目结构:
因为怕vue文件里面的代码过多,所以把css、js文件都单独写在一个文件里面
<template>
<div class="senior-certification-com">...</div>
</template>
<script>
import questionLabel from "./questionLabel";
export default questionLabel;
</script>
<style lang="stylus" scoped>
@import url("./questionLabel.less");
</style>
router.js(路由)
{
path: '/question/questionLabel',
component: () => import('@/myviews/question/questionLabel/questionLabel'),
name: '问答标签',
meta: {
title: '问答标签',
}
}
这些代码看起来都是没问题,但是页面就是展示不出来
经过排查,发现这段代码才是元凶
component: () => import('@/myviews/question/questionLabel/questionLabel'),
解决方法:
component: () => import('@/myviews/question/questionLabel/questionLabel.vue'),
原因:没找到相对应的".vue"文件,按照查找规则,上面的代码是直接找到“.js”文件,所以报错