Skip to content

如何将DesignAble生成的jsonSchema反显在DesignAble上? #1912

Answered by atzcl
sorryljt asked this question in Q&A [2.x]
Discussion options

You must be logged in to vote

大概做以下两步即可

  • json schema 对象递归创建成以 TreeNode 实例为节点的节点树
  • 将这棵树设置到当前的 Workspaceoperation.tree 的下级节点中

这里可以直接使用 @designable/formily 提供的 transformToTreeNode 方法

具体的代码

这里对应上面的第一步

props.onChange?.(transformToTreeNode(JSON.parse(value), Parser))

这里对应上面的第二步

<ViewPanel type="JSONTREE" scrollable={false}>
{(tree, onChange) => (
<SchemaEditorWidget tree={tree} onChange={onChange} />
)}
</ViewPanel>

这里的 ViewPanel render props 部分需要到 designable 那边去看
https://github.com/alibaba/designable/blob/…

Replies: 3 comments 16 replies

Comment options

You must be logged in to vote
13 replies
@wangjie19910615
Comment options

@wangjie19910615
Comment options

@sorryljt
Comment options

@atzcl
Comment options

atzcl Aug 3, 2021
Collaborator

@sorryljt
Comment options

Answer selected by atzcl
Comment options

You must be logged in to vote
3 replies
@sorryljt
Comment options

@janryWang
Comment options

@sorryljt
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants