Vue 报错Failed to mount component: template or render function not defined

简介: Vue 报错Failed to mount component: template or render function not defined

Vue2使用的过程中报错误Failed to mount component: template or render function not defined

20210527153548522.png大概遇到有以下几种情况,简单记录一下。。。

1、页面引用组件时

先看一下当前的目录结构

20210527153548522.png

当前页面的目录结构是vipTag/index.vue主页面;component下的tagRoule.js、tagRoule.scss和tagRoule.vue等组成的组件,因为当前组件逻辑,样式部分比较长,所以做了一下拆分;这个时候我们回到vipTag/index.vue主页面 看一下import

20210527153548522.png

import tagRule from "./components/tagRule";这种情况就导致了无法识别具体引入的文件导致了报错误,改为import tagRule from "./components/tagRule.vue";即可

2、router/index.js路由引用页面时

错误示例

20210527153548522.png

上图所示,component: require('@/views/vipTag/index.vue') 当前的写法导致了报错


原因是:require 是 CommonJS 的模块导入方式,而组件定义时写的 export default 是 ES6 方式,因此require 导入的结果其实是一个含 default 属性的对象,所以 vue 中 component 用这个会报错,而恰好 vue 的命名视图组件注册用 components ,而合理的用法应该是require('xxx.vue').default 或是用 import

20210527153548522.png


相关文章
|
API C++
【Azure 环境】VS Code登录China Azure(Function)报错 An error occurred while signing in: invalid_request - AADSTS65002
An error occurred while signing in: invalid_request - AADSTS65002: Consent between first party application 'c27c220f-ce2f-4904-927d-333864217eeb' and first party resource '797f4846-ba00-4fd7-ba43-dac1f8f63013' must be configured via preauthorization - applications owned and operated by Microsoft mus
657 13
|
缓存 开发工具 C++
VS Code调试Function报错|无法加载Diagnostics.Abstractions怎么办?
在调试 Azure Function 时,可能出现 “Could not load file or assembly 'Microsoft.Extensions.Diagnostics.Abstractions, Version=8.0.0.0'” 错误,导致主机启动失败。本文详细解析该依赖加载错误的成因,并提供基于不同安装方式(NPM 或 MSI)的解决方案,涵盖重装 Core Tools、清理缓存、检查 .NET SDK 版本等操作步骤,同时提供日志排查与 Docker 容器化替代方案,帮助开发者快速恢复本地调试流程。
523 0
|
网络协议 API 网络安全
【Azure Function App】发现部分请求Function App遇见 403.72 报错(请求Body>100KB)
在调用Azure Function的HTTP Trigger时,发送POST请求偶尔出现403错误,且响应为空、Header信息少。经排查发现,当请求Body大于100KB时会触发403.72错误,原因是启用了“Client Certificate mode”为“Optional Interactive User”。解决方法是将该模式设置为“Ignore”。由于TLS重新协商机制限制,大请求体无法正常处理,导致此问题。
498 1
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
675 11
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
579 2
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
398 0
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
存储 网络安全 数据中心
【Azure 应用服务】Function App / App Service 连接 Blob 报错
【Azure 应用服务】Function App / App Service 连接 Blob 报错
239 0
|
JavaScript 前端开发 C++
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题
429 0
|
SQL DataWorks 关系型数据库
DataWorks操作报错合集之如何处理在DI节点同步到OceanBase数据库时,出现SQLException: Not supported feature or function
DataWorks是阿里云提供的一站式大数据开发与治理平台,支持数据集成、数据开发、数据服务、数据质量管理、数据安全管理等全流程数据处理。在使用DataWorks过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
746 0

热门文章

最新文章