【问题标题】:How to type a label on a tcomb form on React Native?如何在 React Native 的 tcomb 表单上键入标签?
【发布时间】:2018-04-03 17:44:18
【问题描述】:

我有这段代码,我想选择每个部分的标签,因为它们是随代码自动生成的。如果我将“WineName”选择为“Wine Name”,则不会发生任何事情。

var type = t.enums({
   type1: 'Red',
   type2: 'Rosé',
   type3: 'White'
});    
var FichaUm = t.struct({
    WineName: t.String,
    harvest: harvest,
    type: type,
    producername: t.String,
    country: country,
    zone: t.String
});

【问题讨论】:

    标签: android ios react-native mobile tcomb


    【解决方案1】:

    要使用带空格的对象属性,您可以使用Bracket notation 来设置对象属性。考虑跟随 sn-ps

    var FichaUm = t.struct({
     ['Wine Name']: t.String,
     harvest: harvest,
     type: type,
     producername: t.String,
     country: country,
     zone: t.String
    });
    

    希望这会有所帮助!

    【讨论】:

    • 感谢您的回答,但由于某种原因,可视化显示:“葡萄酒名称”,“n”小写。
    • 您使用的是哪个visualization
    【解决方案2】:

    您应该能够创建一个选项对象并将其传递给表单,它应该是这样的:

    let options = {
      fields: {
        "sectionName": {
          label: "your label"
        }
      }
    }
    

    然后在表单元素上

    <Form type={FichaUm} options={options}/> 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-10
      相关资源
      最近更新 更多