amis-editor多个版本,运行会提示 缺少依赖 "import { observer } from 'mobx-react';"

kcugc4gi  于 3个月前  发布在  React
关注(0)|答案(2)|浏览(62)
实现场景:

将amis-editor 加入到现有的react项目中。

存在的问题:

使用时会提示缺少"mobx-react"依赖,自己添加"mobx-react"依赖 又会报项目的mobx-react版本不一致

项目中使用方式:

import { Editor } from "amis-editor";
<Editor
        // style={{ height: "calc(100% - 60px) !important" }}
        preview={preview}
        isMobile={mobile}
        onChange={onChange}
        value={{
            type: "page",
            body: "测试",
            title: "标题",
          }}
        theme={"cxd"}
        onSave={onSave}
      />

错误内容:

node_modules/amis-editor/esm/renderer/style-control/Border.js:11:25:
      11 │ import { observer } from 'mobx-react';

    node_modules/amis-editor/esm/renderer/style-control/BoxModel.js:10:25:
      10 │ import { observer } from 'mobx-react';

    node_modules/amis-theme-editor-helper/esm/renderers/Shadow.js:8:25:
      8 │ import { observer } from 'mobx-react';

   node_modules/amis-theme-editor-helper/esm/renderers/Size.js:8:25:
      8 │ import { observer } from 'mobx-react';
hfsqlsce

hfsqlsce1#

👍 Thanks for this!
🏷 I have applied any labels matching special text in your issue.

Please review the labels and make any necessary changes.

wvmv3b1j

wvmv3b1j2#

使用npm i --legacy-peer-deps试试

相关问题