首页 > 解决方案 > t梳反应原生表单选择器无法显示选择的值

问题描述

我有一个反应原生的 ^0.64.0 应用程序。我在 iOS 上运行 t-comb 包import t from 'tcomb-form-native';并将此代码用于表单:

const Form = t.form.Form;
<Form ref={this.formRef} type={SetupOne} options={options} value={this.state.value}/>

在选项道具中,我有以下内容:

let options = {
            fields: {
                terrain: {
                    textColor: 'white',
                    selectTextOnFocus: 'white',
                    optionTextColor: 'white',
                    factory: t.form.Select,
                    help: 'Call it on which terrain you ride this setup',
                    nullOption: {value: '', text: 'Choose the terrain'},
                    options: terrains,
                    stylesheet: stylesheet,
                    title: 'Choose the terrain',
                    itemStyle: {
                        color: 'white',
                    },
                },
                stylesheet: formStyles,
            }
        }

我的地形变量是

 let terrains = [
        { value: 'bikepark', text: 'Bikepark' },
        { value: 'trail', text: 'Trail' }
    ];

我想在选择字段中显示所选值:

选择字段 选择字段 2

我怎样才能做到这一点?

标签: javascriptreact-nativetcomb

解决方案


推荐阅读