如何在tcomb-form-native中向inputText添加值? [英] How to add a value to an inputText in tcomb-form-native?

查看:97
本文介绍了如何在tcomb-form-native中向inputText添加值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是react native的新手,并且我正在使用tcomb-form库为我的应用程序创建表单. 我想向我的某些字段添加默认值,这意味着它们在首次出现时必须默认具有值. 到目前为止,这是我尝试过的操作,但是该字段仍然显示为空:

I'am new in react native , and i'am using tcomb-form library to create forms for my app. I want to add a default values to some of my fields, means when they first appear they must have values by default. This is what i tried so far but the field still appears empty :

this.Position = t.struct({
      PosName: FormFields.String,
    });
fields:{
PosName: {
          placeholder: "Name der Position",
          error: "Dieses Feld ist erforderlich",
          label: "Name der Position",
          value: "some text here ",
          template: Template
        },
//... other fields here
}

推荐答案

您可以使用字段和默认值创建一个对象,然后将其传递给表单元素,如下所示:

You can create an object with your fields and your default values and then pass it to your form element like this:

// your object definition
    let value = {
         PostName: 'some text here',
         {... other fields}
    }

然后在您的渲染器上:

<Form type={this.Position} value={value}

以下是文档: tcomb-form-native默认值

这篇关于如何在tcomb-form-native中向inputText添加值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆