From d5e75109bcb056c7ec348f9ab2eea131e7605c08 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Thu, 30 Oct 2025 15:28:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E7=9A=84=20routes.js=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E5=AF=BC=E5=85=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 问题 应用启动报错: ``` Error: Element type is invalid: expected a string or a class/function but got: object. Check the render method of AppContent. ``` ## 根本原因 模块路径冲突导致导入错误: - `App.js` 导入 `import AppRoutes from './routes'` - 存在两个文件: 1. ✅ `src/routes.js`(空数组)← 被优先导入 2. ❌ `src/routes/index.js`(路由组件)← 应该导入的 Node.js 模块解析优先选择文件而非目录,导致 AppRoutes 被解析为空数组而非 React 组件。 ## 解决方案 删除已废弃的 `src/routes.js`: - 该文件注释说明"保留仅为兼容可能的旧引用" - 内容仅为空数组 `dashRoutes = []` - 删除后 `./routes` 自动解析为 `./routes/index.js` ## 影响 - ✅ 修复应用启动错误 - ✅ 路由正确加载 - ✅ 无其他文件引用此文件(已验证) ## 验证 需要重启开发服务器以应用更改。 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/routes.js | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100755 src/routes.js diff --git a/src/routes.js b/src/routes.js deleted file mode 100755 index a27397ea..00000000 --- a/src/routes.js +++ /dev/null @@ -1,27 +0,0 @@ -/*! - -========================================================= -* Argon Dashboard Chakra PRO - v1.0.0 -========================================================= - -* Product Page: https://www.creative-tim.com/product/argon-dashboard-chakra-pro -* Copyright 2022 Creative Tim (https://www.creative-tim.com/) - -* Designed and Coded by Simmmple & Creative Tim - -========================================================= - -* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -*/ - -import React from "react"; - -// ⚠️ Admin 布局已移除 -// 实际路由配置现在在 /src/App.js 中 -// 此文件保留仅为兼容可能的旧引用 - -// 导出空数组以保持向后兼容 -const dashRoutes = []; - -export default dashRoutes;