根据样式修改TextInput的值(就像我们使用占位符一样)

时间:2018-11-19 19:08:29

标签: react-native tcomb-form-native

我是React-Native的新手

我使用 tcomb-form-native 模块来快速创建表单:

const FormConnex = t.struct({
'email': t.String,
'password' : t.String,
});
...
render() {
    return(
        <KeyboardAwareScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
            <Form ref={c => this._connex = c} type={FormConnex} options={optionsFormConnex} />{}
            <Form ref={c => this._perso = c} type={FormPerso} options={optionsFormPerso} />{}
            <Form ref={c => this._birthdate = c} type={FormBirthdate} options={optionsFormBirthdate} />{}
            <Form ref={c => this._address = c} type={FormAddr} options={optionsFormAddr} />{}
            <Form ref={c => this._role = c} type={FormRole}  />{}
            <Button title={'Créer un compte'} onPress={this.handleSubmit}/>
        </KeyboardAwareScrollView>
    );
}
...

这是我设置表单(例如ex.optionsFormConnex)中包含的af字段属性的方法:

const optionsFormConnex = {
auto: 'placeholders',
label: 'Informations de connexion',
fields: {
    email: {
        keyboardType: 'email-address',
        placeholder: 'E-mail',
    },

    password: {
        password: true,
        secureTextEntry: true,
        placeholder: 'Mot de passe',
    },
},
};

如您所见,定义占位符很容易,但是我不知道如何定义(默认)值。我希望所有字段都具有默认值,以便可以更快地测试我的字段。

此模块的问题在于,似乎我无法访问TextInput组件,或者我不知道该怎么做。

使用此模块,您如何将默认值添加到字段中?

**

编辑:

** 我在这里找到了答案:How to add a value to an inputText in tcomb-form-native?

0 个答案:

没有答案
相关问题