gpt4 book ai didi

json - 使用 EmberJS 和 JSON 模式即时生成表单?

转载 作者:行者123 更新时间:2023-12-04 15:34:11 24 4
gpt4 key购买 nike

我搜索并发现了这个问题( GUI-based or Web-based JSON editor that works like property explorer ),其中有几个指向从 JSON 生成 UI 的资源的链接。

我对展示 emberjs 使用 JSON Schema ( http://json-schema.org/ ) 生成动态表单的任何示例或已知项目感兴趣。项目如:

  • 羊驼毛( http://www.alpacajs.org )
  • json-editor(https://github.com/jdorn/json-editor)

  • 有任何想法吗?

    最佳答案

    是的,您可以根据一些 JSON 轻松地动态生成表单。

    您需要将 JSON 对象映射到路由器(或 Controller )中的键数组:

    model: function() {
    var json = {a: 'red', b: 'yellow', c: 'blue'};
    var items = [], key;
    for (key in json) {
    if (json.hasOwnProperty(key)) {
    items.push({name: key, value: json[key]});
    }
    }
    return items;
    }

    只需使用 each您认为的 helper :
    {{#each field in content}}
    {{field.name}}: {{input type="text" value=field.value}}<br>
    {{/each}}

    我做了一个工作 JSBin用上面的代码。

    关于json - 使用 EmberJS 和 JSON 模式即时生成表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23483550/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com