From 4aed6d340ac7a6bd0443856fb55110ce16b90798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Tue, 3 Feb 2026 19:17:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kbone-miniprogram/troubleshooting.md | 25 +++++++++++++++++++ newapp | 1 - next-env.d.ts | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) delete mode 160000 newapp diff --git a/.cursor/skills/kbone-miniprogram/troubleshooting.md b/.cursor/skills/kbone-miniprogram/troubleshooting.md index 2ddc01b6..62426756 100644 --- a/.cursor/skills/kbone-miniprogram/troubleshooting.md +++ b/.cursor/skills/kbone-miniprogram/troubleshooting.md @@ -199,6 +199,31 @@ resolve: { ## 运行时问题 +### 0. TypeError: eval is not a function + +**错误信息**: +``` +TypeError: eval is not a function + at Object../src/index.jsx (index.js?...) +``` + +**原因**:`npm run mp` 使用 development 模式时,webpack 默认 `devtool: 'eval'`,会注入使用 `eval()` 的代码;小程序环境**不支持** `eval`,因此报错。 + +**解决方案**:在 **webpack.mp.config.js** 中显式关闭 devtool: + +```javascript +module.exports = { + mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', + devtool: false, // 小程序环境不支持 eval,必须关闭 + entry: { ... }, + // ... +} +``` + +重新执行 `npm run mp` 或 `npm run build:mp` 后,再在微信开发者工具中预览即可。 + +--- + ### 1. URLSearchParams 未定义 **错误信息**: diff --git a/newapp b/newapp deleted file mode 160000 index 5f9ae76b..00000000 --- a/newapp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5f9ae76b400232f5b5c9b8cdb2fe21e0dab9cafa diff --git a/next-env.d.ts b/next-env.d.ts index 9edff1c7..c4b7818f 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/types/routes.d.ts"; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.