相关疑难解决方法(0)

函数DocumentReference.set()使用无效数据调用.不支持的字段值:自定义预算对象

下面的代码工作正常,直到今天 但我现在不知道它不起作用并给出了以下错误.你能告诉我为什么吗?

错误:使用无效数据调用函数DocumentReference.set().不支持的字段值:自定义预算对象

 export class Project {
        id: string = null;
        name: string;
        budgetList?: Budget[];
    }

export class Budget {
    id: string;
    amount: number;
    contingency: number = 20;
    budgetGroup: BudgetGroup = new BudgetGroup();
    creationTime: string;
}
Run Code Online (Sandbox Code Playgroud)

码:

  async create(data: DtoProject): Promise<Project> {
    try {
      const projectId: string = this.fireStore.createId();
      const budgets = this.budgetProvider.createBudgets(data.budgetList, projectId);//budgets
      const proj: Project = {
        id: data.id,
        name: data.name,
        budgetList: budgets,//here it has the error
      }
      proj.id = projectId;
      await this.fireStore.doc<Project>(`projects/${projectId}/`).set(proj));//project
      }
 }

  createBudgets(data: Budget[], projectId: …
Run Code Online (Sandbox Code Playgroud)

firebase typescript ionic3 angular google-cloud-firestore

29
推荐指数
3
解决办法
2万
查看次数

React - Formik - 字段数组 - 实现可重复的表单字段

我正在尝试遵循有关使用FieldArrays的 Formik 文档,以便我可以将可重复的表单元素添加到我的表单中。

我还看到了这篇Medium 帖子给出了一个例子。

我学习很慢,无法将文档和实现之间的点联系起来。

我想在我的主表单中有一个按钮,上面写着:“添加数据请求”。

如果选择该按钮,则会显示设置数据配置文件的嵌套表单,以及“添加另一个数据请求”和“删除”按钮。

我已经在我的应用程序的另一个组件中创建了嵌套表单,但我正在努力弄清楚如何使用媒体帖子中的示例来合并嵌套表单(作为可重复元素 - 即有人可能需要 5 个数据请求)。

有没有关于如何实现这一点的例子?

在我的代码中,我基本上遵循了medium post,但尝试链接索引内的数据请求表单组件

<button 
      type="button"
      onClick={() => arrayHelpers.insert(index, <DataRequestForm />)}>
      Add a data request
</button>   
Run Code Online (Sandbox Code Playgroud)

这显然是不正确的,但我不知道如何做到这一点。

根据 Nithin 的回答,我尝试修改嵌入的表单,以便我可以使用 react-select,如下所示,但是我收到一个错误消息:

类型错误:无法读取未定义的属性“值”

import React from "react";
import { Formik, Form, Field, FieldArray, ErrorMessage, withFormik } from "formik";
import Select from "react-select";


import {
  Button,
  Col,
  FormControl,
  FormGroup,
  FormLabel,
  InputGroup,
  Table,
  Row,
  Container
} from "react-bootstrap";

const initialValues = {
  dataType: "",
  title: "",
  description: …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs formik

3
推荐指数
1
解决办法
2453
查看次数