【问题标题】:How to dynamically create refs react native video如何动态创建参考反应原生视频
【发布时间】:2020-04-05 11:35:54
【问题描述】:

既然不接受仅使用字符串,我该如何为视频列表创建动态引用?

例如如何把它变成动态的东西

ref={(ref) => { this.player = ref }}

当你之前可以这样做时

x = ['ref1', 'ref2']
ref={x[index]}

【问题讨论】:

    标签: react-native ref


    【解决方案1】:

    你可以这样试试:-

    constructor(props) {
        super(props)
        ....
        this.myInput = [];
      }
    ...
    render() {            // or return depending on your code
        for (i=0;i<=n;i++) {
            ... your code...   // i will go with TextInput for now
            <TextInput
                ref={(input) => {this.myInput[i]=input}}
                multiline={true}
                style={{ padding: 10, fontSize: 15 * myr, alignSelf: 'center', backgroundColor: 'red' }}
                onChangeText={(text) => Email = text}
                placeholder="Email*"
            />
        }
    }
    

    【讨论】:

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