有几个forEOK吗?

时间:2018-07-09 08:00:45

标签: javascript arrays performance foreach

我正在寻找最佳实践解决方案。我在前端有一个非常嵌套的数据对象来构建表单。数据实例:

MyModel.objects.aggregate(Min('price_range'),Max('price_range'),)

您可以看到我有附件,这就是为什么我使用dropzone(初始化onClick)的原因。必须为每个项目初始化插件。 我使用几个forEach函数来实现它。像这样:

forms: {
  form1: {
    title1: 'title1',
      fields: {
        field1: {
          label: 'field1 label',
            value: null,
            description: ''
        },             
      },
  },
  form2: {
      title2: 'title2',
      description: '',
          fields: [
            {
              title: 'title',
              subsections: [
                {
                  title: 'title',
                  options: [
                    {
                      id: 1,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    },
                    {
                      id: 2,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    }
                  ]
                },
                {
                  title: 'title',
                  options: [
                    {
                      id: 3,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    },
                    {
                      id: 4,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    }
                  ]
                }
              ]

            },
            {
              title: 'title',
              subsections: [
                {
                  title: 'title',
                  options: [
                    {
                      id: 5,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    },
                    {
                      id: 6,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    }
                  ]
                },
                {
                  title: 'title',
                  options: [
                    {
                      id: 7,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    },
                    {
                      id: 8,
                      label: '',
                      answer: '',
                      isSomething: false,
                      attachments: []
                    }
                  ]
                }
              ]
            }
          ]
    }
}

性能还可以吗? 有什么办法可以更好地实现它?

P.S。如果您不赞成投票,那就太好了,请解释原因。谢谢!

0 个答案:

没有答案
相关问题