JSON数据可视化/JSONSchema,以表单的形式编辑 json schema,可用于在线设计组件的配置面板。
React/Mobx/Ant Design
JSONSchema仅用于生成结构化的json数据,需要配合JSONEditor(git地址)渲染其内容。
npm install --save @wibetter/json-schema-editor
import * as React from 'react';
import JSONSchemaEditor from '@wibetter/json-schema-editor';
import '@wibetter/json-schema-editor/dist/index.css';
class IndexDemo extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
jsonSchema: {},
};
}
render() {
const { jsonSchema } = this.state;
return (
<>
<div className="json-action-container">
<div className="json-schema-box">
<JSONSchemaEditor
data={jsonSchema}
onChange={(newJsonSchema) => {
this.setState({
jsonSchema: newJsonSchema,
});
}}
/>
</div>
</div>
</>
);
}
}
name | type | default | desc |
---|---|---|---|
data |
object | {} | 必填项,json schema(带结构的json数据) |
typeList |
object | {} | 非必填,用于设置func、style、data的子项可选类型 |
onChange |
function | () => {} | schemaData内容变动时会触发onChange |