【发布时间】:2020-04-05 11:35:54
【问题描述】:
既然不接受仅使用字符串,我该如何为视频列表创建动态引用?
例如如何把它变成动态的东西
ref={(ref) => { this.player = ref }}
当你之前可以这样做时
x = ['ref1', 'ref2']
ref={x[index]}
【问题讨论】:
标签: react-native ref
既然不接受仅使用字符串,我该如何为视频列表创建动态引用?
例如如何把它变成动态的东西
ref={(ref) => { this.player = ref }}
当你之前可以这样做时
x = ['ref1', 'ref2']
ref={x[index]}
【问题讨论】:
标签: react-native ref
你可以这样试试:-
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*"
/>
}
}
【讨论】: