baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.18k stars 2.49k forks source link

Next.js使用Amis-Editor报错[mobx-state-tree] expected mobx-state-tree node as argument 1, got undefined instead #10872

Closed ryangamil closed 1 month ago

ryangamil commented 1 month ago

描述问题:

想在Next.js项目中使用编辑器,根据可视化编辑器的文档 https://github.com/aisuda/amis-editor-demo “在其他项目中使用amis-editor”章节(图1)的使用方式引入报错 1、使用npx create-next-app 创建项目后,直接引入Amis-Editor后运行报错mobx-react未找到(图2) 2、手动引入与amis相同版本的mobx-react后再运行,报错[mobx-state-tree] expected mobx-state-tree node as argument 1, got undefined instead(图3)

截图或视频:

3c10ff3c65883da50484066a4e5a4ee2

5d64f209a835793c13adb9c7839a60ec

6443ef81d58db4004f7e6f8d89cdec57

如何复现(请务必完整填写下面内容):

  1. 你是如何使用 amis 的? npm node版本18.19.1

  2. amis 版本是什么?请先在最新 beta 版本测试问题是否存在 amis-editor版本为最新的6.8.0

  3. 粘贴有问题的完整 amis schema 代码:

    const amisJSON = {
    type: "page",
    body: "测试",
    title: "标题",
    }
  4. 操作步骤 此处提供一个rep:https://github.com/ryangamil/nextjs-amis-editor-demo 执行 npm i --legacy-peer-deps npm run dev 后可在网页中查看

ryangamil commented 1 month ago
const nextConfig = {
    reactStrictMode: false,
};

在nextConfig中关闭react的严格模式可以打开了