amis
amis copied to clipboard
在 React 原生项目中引入amis编辑器报错
实现场景:
在React 原生项目中引入amis编辑器组件来使用editor
代码展示:
import React from 'react';
import { Editor } from 'amis-editor';
function App(props : any) {
let store = {
preview: false,
schema: { body: 'aaa', title: "Hello world", type: "page" },
updateSchema: (value: string) => { console.log("updateSchema方法执行了") },
isMobile: false
}
let schemaUrl = "/schema.json"
let iframeUrl = "/editor.html"
let host = `${window.location.protocol}//${window.location.host}`;
// 如果在 gh-pages 里面
if (/^\/amis-editor-demo/.test(window.location.pathname)) {
host += '/amis-editor';
iframeUrl = '/amis-editor-demo' + iframeUrl;
}
return (
<Editor
theme={'cxd'}
preview={store.preview}
value={store.schema}
onChange={(value: any) => store.updateSchema(value)}
className="is-fixed"
$schemaUrl={schemaUrl}
iframeUrl={iframeUrl}
isMobile={store.isMobile}
/>
)
}
export default App;
报错:

code here...
感觉可能是 react 和 react dom 版本不一样,参考 https://github.com/aisuda/amis-editor-demo 项目